fsleyes_props.widgets
This module provides functions to generate Generate wx GUI widgets
which allow the user to edit the properties of a HasProperties
instance.
Most of the functions in this module are not intended to be called directly -
they are used by the build module. However, a few functions defined
here are made available at the fsleyes_props namespace level, and are
intended to be called by application code:
Given
hasProps(aHasPropertiesinstance),propName(the name of a property ofhasProps), andparent, a GUI object, creates and returns a widget, or a panel containing widgets, which may be used to edit the property value.Creeates a widget for a specific value in the specified list property.
Creates a widget for every value in the given list property.
Creates a button which controls synchronisation of the specified property on the given
hasPropsinstance, with the corresponding property on its parent.Binds the given widget to the specified property.
Unbinds the given widget from the specified property, assumed to have been previously bound via the
bindWidget()function.
The other functions defined in this module are used by the build
module, which generates a GUI from a view specification. The following
functions are available:
_FilePathCreates and returns a panel containing a
wx.TextCtrland awx.Button.
_StringCreates and returns a
wx.TextCtrlobject, allowing the user to edit the givenpropVal(managed by aStringinstance).
_RealCreates and returns a widget allowing the user to edit the given
Realproperty value.
_IntCreates and returns a widget allowing the user to edit the given
Intproperty value.
_PercentageCreates and returns a widget allowing the user to edit the given
Percentageproperty value.
_ColourCreates and returns a
ColourButtonwidget, allowing the user to modify the givenColourproperty value.
_ColourMapCreates and returns a combobox, allowing the user to change the value of the given
ColourMapproperty value.
_LinkBoxCreates a 'link' button which toggles synchronisation between the property on the given
hasPropsinstance, and its parent.
Widgets for some other property types are implemented in separate modules, purely to keep module file sizes down:
_List
_BoundsCreates and returns a panel containing sliders/spinboxes which allow the user to edit the low/high values along each dimension of the given
Boundsproperty value.
_PointCreates and returns a
SliderSpinPanelallowing the user to edit the low/high values along each dimension of the givenPointproperty value.
_ChoiceCreates and returns a widget allowing the user to modify the given
Choiceproperty value.
_BooleanCreates and returns a
wx.CheckBox, allowing the user to set the givenBooleanproperty value.
_NumberCreates and returns a widget allowing the user to edit the given
Numberproperty value.Warning
The
widgets_listmodule has not been looked at in a while, and is probably broken.
While all of these functions have a standardised signature, some of them
(e.g. the _Colour function) accept extra arguments which provide some
level of customisation. You can provide these arguments indirectly in the
ViewItem specification for a specific property. For example:
import fsleyes_props as props
class MyObj(props.HasProperties):
myColour = props.Colour()
myBoolean = props.Boolean()
view = props.VGroup((
# Give the colour button a size of 32 * 32
props.Widget('myColour', size=(32, 32)),
# Use a toggle button for the boolean property,
# using 'boolean.png' as the button icon
props.Widget('myBoolean', icon='boolean.png') ))
myobj = MyObj()
dlg = props.buildDialog(None, myobj, view=view)
dlg.ShowModal()
- fsleyes_props.widgets.makeSyncWidget(parent, hasProps, propName, **kwargs)[source]
Creates a button which controls synchronisation of the specified property on the given
hasPropsinstance, with the corresponding property on its parent.See the
makeWidget()function for a description of the arguments.
- fsleyes_props.widgets.makeWidget(parent, hasProps, propName, **kwargs)[source]
Given
hasProps(aHasPropertiesinstance),propName(the name of a property ofhasProps), andparent, a GUI object, creates and returns a widget, or a panel containing widgets, which may be used to edit the property value.- Parameters:
parent – A
wxobject to be used as the parent for the generated widget(s).hasProps – A
HasPropertiesinstance.propName (str) – Name of the
PropertyBaseproperty to generate a widget for.kwargs – Type specific arguments.
- fsleyes_props.widgets.makeListWidget(parent, hasProps, propName, index, **kwargs)[source]
Creeates a widget for a specific value in the specified list property.
- fsleyes_props.widgets.makeListWidgets(parent, hasProps, propName, **kwargs)[source]
Creates a widget for every value in the given list property.
- fsleyes_props.widgets.bindWidget(widget, hasProps, propName, evTypes, widgetGet=None, widgetSet=None)[source]
Binds the given widget to the specified property. See the
_propBind()method for details of the arguments.
- fsleyes_props.widgets.bindListWidgets(widgets, hasProps, propName, evTypes, widgetSets=None, widgetGets=None)[source]
Binds the given sequence of widgets to each of the values in the specified list property.
- fsleyes_props.widgets.unbindWidget(widget, hasProps, propName, evTypes)[source]
Unbinds the given widget from the specified property, assumed to have been previously bound via the
bindWidget()function.