Difference between revisions of "Preferences"
Jump to navigation
Jump to search
Line 18: | Line 18: | ||
! scope="col" class="unsortable" | Description | ! scope="col" class="unsortable" | Description | ||
|- | |- | ||
− | |add(id, value, min=None, max=None, hidden=False) | + | |add(id, value, min=None, max=None, hidden=False, items=None) |
− | |Add a preference with the specified <tt>id</tt> and default <tt>value</tt>. If the value is of type Integer or Float, <tt>min</tt> and <tt>max</tt> can be specified to define a supported range. In this case, the preference will be displayed as a slider. The preference can be hidden from the Preferences dialog by setting <tt>hidden=True</tt>. Supported values are Bool, Int, Float, and String. | + | |Add a preference with the specified <tt>id</tt> and default <tt>value</tt>. If the value is of type Integer or Float, <tt>min</tt> and <tt>max</tt> can be specified to define a supported range. In this case, the preference will be displayed as a slider. If value is of type Integer and <tt>items</tt> points to a list of strings, the preference will be displayed as a list popup. The preference can be hidden from the Preferences dialog by setting <tt>hidden=True</tt>. Supported values are Bool, Int, Float, and String. |
|- | |- | ||
|addHandler(id, function) | |addHandler(id, function) |
Latest revision as of 21:52, 25 July 2018
The Preferences object (accessed through the fx.prefs attribute) provides access to the Silhouette preferences map.
Preferences are accessed using the map key syntax, where pref_id is a string:
# query a preference value
value = fx.prefs[pref_id]
# set a preference value
fx.prefs[pref_id] = value
Scripts can add new preferences to the system and get notified when the preference is changed.
Methods
Name | Description |
---|---|
add(id, value, min=None, max=None, hidden=False, items=None) | Add a preference with the specified id and default value. If the value is of type Integer or Float, min and max can be specified to define a supported range. In this case, the preference will be displayed as a slider. If value is of type Integer and items points to a list of strings, the preference will be displayed as a list popup. The preference can be hidden from the Preferences dialog by setting hidden=True. Supported values are Bool, Int, Float, and String. |
addHandler(id, function) | Adds a new preference handler for the preference with the specified id. When the preference is changed, the function will be called, with no arguments. |
keys() | Returns a List of all of the registered preference ids/keys. |