Difference between revisions of "Preferences"

From Silhouette Wiki
Jump to navigation Jump to search
(Created page with "The Preferences object (accessed through the <tt>fx.prefs</tt> attribute) provides access to the Silhouette preferences map. Preferences are accessed using the map key syntax...")
 
Line 19: Line 19:
 
|-
 
|-
 
|add(id, value, min=None, max=None, hidden=False)
 
|add(id, value, min=None, max=None, hidden=False)
|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>.
+
|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.
 
|-
 
|-
 
|addHandler(id, function)
 
|addHandler(id, function)

Revision as of 20:56, 18 November 2012

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) 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. 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.