fsleyes.toolbar¶
This module provides the FSLeyesToolBar class, the base class
for all toolbars in FSLeyes.
-
class
fsleyes.toolbar.FSLeyesToolBar(parent, overlayList, displayCtx, frame, height=32, orient=<MagicMock name='mock.HORIZONTAL' id='281473489697664'>, *args, **kwargs)[source]¶ Bases:
fsleyes.panel.FSLeyesPanelBase class for all FSLeyes toolbars.
The
FSLeyesToolBaris a regularwx.PyPanelwhich to which a group of tools can be added, where a tool may be anywxcontrol.See also the
ControlToolBar, which is the true base-class for all toolbars that are added to FSLeyes view panels.Tools can be added to a
FSLeyesToolBarwith the following methods:Adds the given tool to this
FSLeyesToolBar.Inserts the given tool into this
FSLeyesToolBar, at the specified index.Inserts the given sequence of tools into this
FSLeyesToolBar, at the specified index.Replaces all of the existing tools in this
FSLeyesToolBarwith the given sequence of tools.Creates a panel containing the given tool, and a label for the tool.
When the horizontal size of a
FSLeyesToolBarbecomes too small to display all of its tools, the toolbar is compressed: some tools are hidden, and buttons are displayed on each end of the toolbar, allowing the user to scroll through the toolbar, to access the hidden tools. The user may also use the mouse wheel to scroll through the toolbar.A collapsed
FSLeyesToolBarlooks something like this:
-
__init__(parent, overlayList, displayCtx, frame, height=32, orient=<MagicMock name='mock.HORIZONTAL' id='281473489697664'>, *args, **kwargs)[source]¶ Create a
FSLeyesToolBar.- Parameters
parent – The
wxparent object.overlayList – The
OverlayList, containing all overlays being displayed.displayCtx – A
DisplayContext, which defines how the overlays are to be displayed.frame – The
FSLeyesFrameobject.height – Desired toolbar height in pixels. This value is used to look up appropriately sized left/right arrow icons.
actionz – A dictionary of actions passed through to the
ActionProvider.__init__().
All other arguments are passed through to
FSLeyesPanel.__init__().
-
GetOrient()[source]¶ Returns the orientation of this
FSLeyesToolBar, eitherwx.HORIZONTALorwx.VERTICAL.
-
MakeLabelledTool(tool, labelText, labelSide=<MagicMock name='mock.TOP' id='281473489574448'>, expand=False)[source]¶ Creates a panel containing the given tool, and a label for the tool. The panel is returned, but is not added to this
FSLeyesToolBar- you will have to do that yourself, e.g.:labelledTool = toolbar.MakeLabelledTool(tool, 'Label', wx.BOTTOM) toolbar.AddTool(labelledTool)
- Parameters
tool – A
wxcontrol.labelText – A label for the tool.
labelSide – Which side of the tool to put the label -
wx.TOP,wx.BOTTOM,wx.LEFT, orwx.RIGHT.expand – Defaults to
False. IfTrue, the widget and label will be set up so they expand to fit all available space
-
Enable(*args, **kwargs)[source]¶ Enables/disables all tools in this
FSLeyesToolBar.- Parameters
args – Passed to the
Enablemethod of each tool.kwargs – Passed to the
Enablemethod of each tool.
-
AddDivider()[source]¶ Adds a
ToolBarDividerto the end of the toolbar.
-
InsertDivider(index=None)[source]¶ Inserts a
ToolBarDividerinto the toolbar at the specifiedindex.
-
InsertTools(tools, index=None)[source]¶ Inserts the given sequence of tools into this
FSLeyesToolBar, at the specified index.- Parameters
tools – A sequence of tools to add.
index – Insert the tools before this index (default: end).
-
SetTools(tools, destroy=False)[source]¶ Replaces all of the existing tools in this
FSLeyesToolBarwith the given sequence of tools.- Parameters
tools – Sequence of new tools to add.
destroy – If
Trueall of the old tools are destroyed.
-
InsertTool(tool, index=None, postevent=True, redraw=True)[source]¶ Inserts the given tool into this
FSLeyesToolBar, at the specified index.- Parameters
tool – The tool to insert.
index – Index to insert the tool.
postevent – If
True, aToolBarEventwill be generated. PassFalseto suppress this event.redraw – If
True, the toolbar is redrawn. PassFalseto suppress this behaviour.
-
DoGetBestSize()[source]¶ Calculates and returns the best size for this toolbar, simply the minimum size that will fit all tools.
This method is called by
wxwhen this toolbar is laid out.
-
ClearTools(destroy=False, startIdx=None, endIdx=None, postevent=True)[source]¶ Removes all tools, or a range of tools, from this
FSLeyesToolBar.- Parameters
destroy – If
True, the removed tools are destroyed.startIdx – Start index of tools to remove. If not provided, defaults to 0.
endIdx – End index of tools to remove (exclusive). If not provided, defaults to
GetToolCount().postevent – If
True, aToolBarEventwill be generated. Set toFalseto suppress the event.
-
_FSLeyesToolBar__drawToolBar(*a)¶ Draws this
FSLeyesToolBar.If the toolbar is big enough, all tools are drawn. Otherwise, the method figures out out how many tools can be drawn, and which tools to draw, given the current size.
-
_FSLeyesToolBar__onLeftButton(ev=None)¶ Called when the left toolbar button is pressed.
If the toolbar is compressed, it is scrolled to the left.
-
_FSLeyesToolBar__onMouseWheel(ev)¶ Called when the mouse wheel is rotated on this
FSLeyesToolBar.Calls
__onLeftButton()or__onRightButton(), depending on the rotation direction.
-
_FSLeyesToolBar__onRightButton(ev=None)¶ Called when the right toolbar button is pressed.
If the toolbar is compressed, it is scrolled to the right.
-
__module__= 'fsleyes.toolbar'¶
-
-
fsleyes.toolbar.EVT_TOOLBAR_EVENT= <MagicMock id='281473527385680'>¶ Identifier for the
ToolBarEventevent.
-
fsleyes.toolbar.ToolBarEvent= <MagicMock id='281473527385680'>¶ Event emitted when one or more tools is/are added/removed to/from a
FSLeyesToolBar.
-
class
fsleyes.toolbar.ToolBarDivider(parent, width=10, height=32, orient=<MagicMock name='mock.VERTICAL' id='281473489695024'>)[source]¶ Bases:
__main__.MockClassAn empty
wx.Panelintended to be used for dividing space in aFSLeyesToolBar.-
__module__= 'fsleyes.toolbar'¶
-