fsleyes_props.widgets_choice
¶
This module provides the _Choice()
function, which is imported into
the widgets
module namespace. It is separated purely to keep the
widgets
module file size down.
-
fsleyes_props.widgets_choice.
_Choice
(parent, hasProps, propObj, propVal, labels=None, icons=None, fixChoices=None, style=None, **kwargs)¶ Creates and returns a widget allowing the user to modify the given
Choice
property value.By default,
wx.Choice
widget is used. However, if theicons
argument is specified, aBitmapRadioBox
is used instead.Parameters: - labels –
A dict of
{choice : label}
mappings, specifying the label to be displayed for each choice. If not provided, the string representation of each choice is used. Not used if theicons
argument is specified.Note
If the
Choice
property is dynamic (i.e. choices are going to be added/removed during program execution), you must ensure that thelabels
dictionary contains a value for all possible choices, not just the initial choices.As an alternative to passing in a
dict
, you may also setlabels
to a function. In this case, thelabels
function must accept a single choice value as its only argument, and return a label for that choice. - icons – If provided, a
BitmapRadioBox
is used instead of awx.Choice
widget. Theicons
should be a dictionary of{ choice : imageFile}
mappings, containing an icon files to be used for each choice. Theicons
dictionary may alternately contain{ choice : (selectedImageFile, unselectedImageFile) }
mappings, which specifies separate icons to be used when the corresponding choice is selected or not selected. - fixChoices – If provided, must be a sequence of valid choice values. If provided, the widget will be limited to displaying only these choices. All other possible choice values will be ignored.
- style – Passed through to the
BitmapRadioBox.__init__()
method. Not used if noicons
were provided.
See the
widgets._String()
documentation for details on the other parameters.- labels –