Changes

From Gramps

Addons development

204 bytes added, 09:02, 8 October 2013
Config: Modified example of config initialisation
Some addons may want to have persistent data (data settings that remain between sessions). You can handle this yourself, or you can use Gramps' built-in configure system.
In At the top of the source file that defines the settingsof your addon, you would do this:
from config import configas configman cm config = configconfigman.register_manager("view_placetreeview_0grampletname") cm# register the values to save: config.register("section.variable1option-name1", value1) cmconfig.register("section.variable2option-name2", value2)
...
cm# load an existing file, if one: config.initload() # save it, it case it didn't exist: config.save() This will create the file "grampletname.ini" and put in the same directory as the addon. If the settings file already exists, it remains intact.
This will create the file "view_placetreeview_0.ini" and put in the same directory as the addon. In the addon, you can then:
x = cm.get("section.variable1option-name1") cm.set("section.variable1option-name1", 3)
and when this code is exiting, you might want to save the config. In a Gramplet that would be:
from config import config
cm = config.get_manager("view_placetreeview_0grampletname") x = cm.get("section.variable1option-name1")
=== Localization ===
38
edits

Navigation menu