Customizing the Preferences Screen
Customizing the preferences screen is accomplished by modifying config.preferences, which is a dictionary mapping from vbox style to a list of preferences to be placed in that vbox. Modifying this dictionary and lists can move preferences around, and eliminate preferences entirely. It may be desirable to create new vbox styles, by using style.create .
Alternative, one can position preferences using config.preference_positions .
To create an entirely new preference, create it with _Preference, _SliderPreference, or _VolumePreference, and then add it to an appropriate list in config.preferences.
Function: _Preference( | name, field, values, base=...) |
This is a class that's used to represent a multiple-choice preference.
name - The name of this preference. It will be displayed to the user.
variable - The field on the base object that will be assigned the selected value. This field must exist.
values - A list of value name, value, condition triples. The value name is the name of this value that will be shown to the user. The value is the literal python value that will be assigned if this value is selected. The condition is a condition that will be evaluated to determine if this is a legal value. If no conditions are true, this preference will not be displayed to the user. A condition of None is always considered to be True.
base - The base object on which the variable is read from and set. This defaults to _preferences, the user preferences object.
Function: _SliderPreference( | name, range, get, set, enable='True') |
A class that represents a preference that is controlled by a slider.
set - The name of this preference, that is shown to the user.
range - An integer giving the maximum value of this slider. The slider goes from 0 to range.
get - A function that's called to get the initial value of the slider. It's called with no arguments, and should return an integet between 0 and range, inclusive.
set - A function that's called when the value of the slider is set by the user. It is called with a single integer, in the range 0 to range, inclusive.
enable - A string giving a python expression. If the expression is evaluates to false, this preference is not shown.
Function: _VolumePreference( | name, mixer, enable='True', sound='None', channel=0) |
This represents a preference that controls one of the volumes in the system. It is represented as a slider bar, and a button that can be pushed to play a sample sound on a channel.
name - The name of this preference, as shown to the user.
mixer - The mixer this preference controls.
enable - A string giving a python expression. If the expression is evaluates to false, this preference is not shown.
sound - A string that is evaluated to yield another string. The yielded string is expected to give a sound file, which is played as the sample sound. (We apologize for the convolution of this.)
channel - The number of the channel the sample sound is played on.