From Silhouette Wiki
Revision as of 21:52, 25 July 2018 by Paul (talk | contribs) (→‎Methods)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.


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.