I have a Gnome applet written in Python. In order to save configuration data/settings, it creates a file ~/.appname
.
However, this prevents multiple instances of the applet from being added to the panel because each cannot have its own settings.
How can I store the settings in a way that allows each instance to have its own unique settings?
Update: I specifically want to know how to store settings per instance.
The recommend way for an applet would be to use GConf to store preferences and to use one key per instance so that you can store individual settings. From Panel Applet GConf Utilities:
Applets typically define a set of preferences using a schemas file and panel_applet_add_preferences(). Such preferences apply only to an individual applet instance. For example, you may add two clock applets to the panel and configure them differently.
In order for the preferences to only apply to a single applet, each applet must have a seperate GConf key for each of these preferences. The methods described below provide convient wrappers around the usual GConfClient functions and operate on these per-applet keys.
Python example with the applet:
import gconf
client = gconf.client_get_default()
gconf_root_key = applet.get_preferences_key()
client.set_string( gconf_root_key + "/myvar", "foobar")
myvar = client.get_string( gconf_root_key + "/myvar")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With