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
(aHasProperties
instance),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
hasProps
instance, 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:
_FilePath
Creates and returns a panel containing a
wx.TextCtrl
and awx.Button
.
_String
Creates and returns a
wx.TextCtrl
object, allowing the user to edit the givenpropVal
(managed by aString
instance).
_Real
Creates and returns a widget allowing the user to edit the given
Real
property value.
_Int
Creates and returns a widget allowing the user to edit the given
Int
property value.
_Percentage
Creates and returns a widget allowing the user to edit the given
Percentage
property value.
_Colour
Creates and returns a
ColourButton
widget, allowing the user to modify the givenColour
property value.
_ColourMap
Creates and returns a combobox, allowing the user to change the value of the given
ColourMap
property value.
_LinkBox
Creates a 'link' button which toggles synchronisation between the property on the given
hasProps
instance, and its parent.
Widgets for some other property types are implemented in separate modules, purely to keep module file sizes down:
_List
_Bounds
Creates and returns a panel containing sliders/spinboxes which allow the user to edit the low/high values along each dimension of the given
Bounds
property value.
_Point
Creates and returns a
SliderSpinPanel
allowing the user to edit the low/high values along each dimension of the givenPoint
property value.
_Choice
Creates and returns a widget allowing the user to modify the given
Choice
property value.
_Boolean
Creates and returns a
wx.CheckBox
, allowing the user to set the givenBoolean
property value.
_Number
Creates and returns a widget allowing the user to edit the given
Number
property value.Warning
The
widgets_list
module 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
hasProps
instance, 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
(aHasProperties
instance),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
wx
object to be used as the parent for the generated widget(s).hasProps – A
HasProperties
instance.propName (str) – Name of the
PropertyBase
property 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.