settings
SettingsManager ¶
SettingsManager(parent=None)
Bases: QObject
Persistent settings manager.
This class uses Qt's QSettings class which abstracts platform-specific
locations for persistent settings. For example, on Windows this is the
registry, and on Linux it's typically ~/.config/
Beyond maintaining settings, the GUI can also register widgets with particular settings so that they may be saved to a setting when changed, and updated from stored settings when the application is loaded.
You should NOT need to instantiate a SettingsManager yourself. Instead, you should opt to import and use the global CONF object like
from pychamber.settings import CONF
Attributes:
-
settingsChanged
(
PySide6.QtCore.Signal
) –Signal emitted when settings are changed
-
widget_fns
(
dict
) –Dictionary of QWidget names, and their getter/setter methods. This is used when updating widgets with existing settings or when updating settings from widgets.
__getitem__ ¶
__getitem__(key)
Tries to retrive the value specified by key.
If the setting has been registered, it will be cast to the appropriate type before being returned
Parameters:
-
key
(
str
) –The setting name
Returns:
-
Any
–The value associated with the key
register_widgets ¶
register_widgets(widget_map)
Registers widgets with the settings object.
When creating widgets with values you want to be persistent, you can register them by creating a widget map and calling this function. The widget_map should be of the form:
widget_map = {
"<key>": (<widget>, <default value>, <type>),
}
Parameters:
-
widget_map
(
dict
) –A dictionary of the type described
update_widgets_from_settings ¶
update_widgets_from_settings()
Updates registered widgets from the stored settings.