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
Choiceproperty value.By default,
wx.Choicewidget is used. However, if theiconsargument is specified, aBitmapRadioBoxis 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 theiconsargument is specified.Note
If the
Choiceproperty is dynamic (i.e. choices are going to be added/removed during program execution), you must ensure that thelabelsdictionary contains a value for all possible choices, not just the initial choices.As an alternative to passing in a
dict, you may also setlabelsto a function. In this case, thelabelsfunction must accept a single choice value as its only argument, and return a label for that choice.icons – If provided, a
BitmapRadioBoxis used instead of awx.Choicewidget. Theiconsshould be a dictionary of{ choice : imageFile}mappings, containing an icon files to be used for each choice. Theiconsdictionary 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 noiconswere provided.
See the
widgets._String()documentation for details on the other parameters.