python.settings.user_settings module

class UserSettings(bundle)[source]

Bases: object

Handles settings per user. This class is a toolkit specific wrapper around QSettings, making it easy to store and retrieve settings.

Each setting is handled using a Scope which allows the client code to determine the scale of the setting. Using the scope, you can define global settings (which is the default), per project, per site, per configuration and per app instance.

SCOPE_CONFIG = 3
SCOPE_ENGINE = 5
SCOPE_GLOBAL = 0
SCOPE_INSTANCE = 4
SCOPE_PROJECT = 2
SCOPE_SITE = 1
retrieve(name, default=None, scope=0)[source]

Retrieves a setting for a particular app for the current login.

Parameters:
  • name – Name of the setting to store.
  • default – Default value to return if the setting is not stored.
  • scope – The scope associated with this setting.
Returns:

The stored value, default if the value is not available

store(name, value, scope=0)[source]

Stores a setting for an app. This setting is tied to the current login.

Parameters:
  • name – Name of the setting to store
  • value – Value to store. Use simple types such as ints, strings, dicts etc. In the interest of cross pyside/pyqt compatibility, any QStrings or QVariants passed in via value will be converted to strs and native python types. Unicode strs will be converted to utf-8.
  • scope – The scope for this settings value, as defined by the constants belonging to this class.