5.1.4. Prefs — Manages user preferences¶
| Threading: | This module is thread safe |
|---|
The Prefs module allows the developer to define a set of user preferences for a plug-in. The framework automatically handles the storage of preferences, allows the user to modify the stored values and provides easy access to the stored values from within the plug-in.
TODO: More information
Note
Although preferences are managed by the framework, it is the responsibility of the developer to add an item for displaying the preference editor to the plug-in’s menu. See PrefsItem for more information.
This module defines the following functions:
- Prefs.Get(id)¶
Returns the value of a given preference.
Parameter: id (str) – The identifier of the preference to retrieve Returns: The value assigned to the given preference Return type: str
- Prefs.Set(id, value)¶
Sets the value of a given preference.
Parameters: - id (str) – The identifier of the preference to set
- value (str) – The value to store
- Prefs.Add(id, type, default, label, **kwargs)¶
Adds a new preference.
Note
This function requires arguments in the same format as the DefaultPrefs.json file. More information on preferences, including available types and optional extra arguments, can be found in the Bundles section.
Parameters: - id (str) – The identifier of the preference to add
- type (str) – The type of preference to add
- default (str) – The default value of the preference
- label (str) – The label to display in the preference editor (this string is automatically localized)
Note
This function should only be called from within the CreatePrefs() function.
- Prefs.Reset()¶
- Resets all preferences, restoring their default values.
- Prefs.SetDialogTitle(dialogTitle)¶
Sets the text used for the title in the preference editor dialog.
Parameter: dialogTitle (str) – The text to display