fsleyes_widgets.widgetlist
This module provides the WidgetList class, which displays a list
of widgets.
- class fsleyes_widgets.widgetlist.WidgetList(parent, style=0, minHeight=-1)[source]
Bases:
ScrolledPanelA scrollable list of widgets.
The
WidgetListprovides a number of features:Widgets can be grouped.
A label can be shown next to each widget.
Widget groups can be collapsed/expanded.
Widgets and groups can be dynamically added/removed.
The most important methods are:
A
WidgetListlooks something like this:A
WidgetListemits aWidgetListChangeEventwhenever its contents change.Create a
WidgetList.- Parameters:
parent – The
wxparent object.style – Passed through to
wx.ScrolledPanel.__init__minHeight – Minimum height of each row
- DoGetBestSize()[source]
Returns the best size for the widget list, with all group widgets expanded.
- SetColours(odd=None, even=None, group=None)[source]
Sets the colours used on this
WidgetList.Each argument is assumed to be a tuple of
(r, g, b)values, each in the range[0 - 255].- Parameters:
odd – Background colour for widgets on odd rows.
even – Background colour for widgets on even rows.
group – Border/title colour for widget groups.
- HasGroup(groupName)[source]
Returns
Trueif thisWidgetListcontains a group with the specified name.
- RenameGroup(groupName, newDisplayName)[source]
Changes the display name of the specified group.
Note
This method only changes the display name of a group, not the group identifier name. See the
AddGroup()method.- Parameters:
groupName – Name of the group.
newDisplayName – New display name for the group.
- AddGroup(groupName, displayName=None)[source]
Add a new group to this
WidgetList.A
ValueErroris raised if a group with the specified name already exists.- Parameters:
groupName – The name of the group - this is used as an identifier for the group.
displayName – A string to be shown in the title bar for the group. This can be changed later via the
RenameGroup()method.
- GetWidgets(groupName=None)[source]
Returns a list containing all of the widgets that have been added to this
WidgetList.- Parameters:
groupName – If provided, only widgets in the specified group will be returned. Otherwise, ungrouped widgets are returned.
- AddWidget(widget, displayName, tooltip=None, groupName=None)[source]
Add an arbitrary widget to the property list.
If the
groupNameis not provided, the widget is added to a list of top level widgets, which appear at the top of the list, above any groups. Otherwise, the widget is added to the collapsible panel corresponding to the specified group.A
ValueErroris raised if the widget is already contained in the list.- Parameters:
widget – The widget to add to the list.
displayName – The widget label/display name.
tooltip – A tooltip for the widget.
groupName –
- Name of the group to which the widget should be
added.
Note
The provided
widgetmay also be awx.Sizerinstances, although support for this is basic. Specifically, only one level of nesting is possible, i.e. the providedwx.Sizermay not have any otherwx.Sizerinstances as its children.
- AddSpace(groupName=None)[source]
Adds some empty vertical space to the widget list.
- Parameters:
groupName – Name of the group tio which the space should be added. If not specified, the space is added to the top level widget list - see the
AddWidget()method.
- RemoveWidget(widget, groupName=None)[source]
Removes and destroys the specified widget from this
WidgetList.- Parameters:
widget – The widget to remove.
groupName – Name of the group in which the widget is contained.
- RemoveGroup(groupName)[source]
Removes the specified group, and destroys all of the widgets contained within it.
- ClearGroup(groupName)[source]
Removes and destroys all widgets in the specified group, but does not remove the group.
- GroupSize(groupName)[source]
Returns the number of widgets that have been added to the specified group.
- fsleyes_widgets.widgetlist.WidgetListChangeEvent
Event emitted by a
WidgetListwhen its contents change.
- fsleyes_widgets.widgetlist.WidgetListExpandEvent
Event emitted by a
WidgetListwhen a group is expanded or collapsed.
- fsleyes_widgets.widgetlist.EVT_WL_CHANGE_EVENT = <wx.core.PyEventBinder object>
Identifier for the
WidgetListChangeEvent.
- fsleyes_widgets.widgetlist.EVT_WL_EXPAND_EVENT = <wx.core.PyEventBinder object>
Identifier for the
WidgetListExpandEvent.
- fsleyes_widgets.widgetlist.WL_ONE_EXPANDED = 1
WidgetListstyle flag. When applied, at most one group will be expanded at any one time.