fsleyes.toolbar
¶
This module provides the FSLeyesToolBar
class, the base class
for all toolbars in FSLeyes.
- class fsleyes.toolbar.FSLeyesToolBar(parent, overlayList, displayCtx, viewPanel, height=32, orient=<MagicMock name='mock.HORIZONTAL' id='140604703000368'>, *args, **kwargs)[source]¶
Bases:
fsleyes.panel.FSLeyesPanel
Base class for all FSLeyes toolbars.
The
FSLeyesToolBar
is a regularwx.PyPanel
which to which a group of tools can be added, where a tool may be anywx
control.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
FSLeyesToolBar
with 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
FSLeyesToolBar
with the given sequence of tools.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.::.When the horizontal size of a
FSLeyesToolBar
becomes 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
FSLeyesToolBar
looks something like this:- __init__(parent, overlayList, displayCtx, viewPanel, height=32, orient=<MagicMock name='mock.HORIZONTAL' id='140604703000368'>, *args, **kwargs)[source]¶
Create a
FSLeyesToolBar
.- Parameters
parent – The
wx
parent object.overlayList – The
OverlayList
, containing all overlays being displayed.displayCtx – A
DisplayContext
, which defines how the overlays are to be displayed.viewPanel – The
ViewPanel
that owns this toolbar.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.HORIZONTAL
orwx.VERTICAL
.
- MakeLabelledTool(tool, labelText, labelSide=<MagicMock name='mock.TOP' id='140604700334528'>, 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
wx
control.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
Enable
method of each tool.kwargs – Passed to the
Enable
method of each tool.
- AddDivider()[source]¶
Adds a
ToolBarDivider
to the end of the toolbar.
- InsertDivider(index=None)[source]¶
Inserts a
ToolBarDivider
into 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
FSLeyesToolBar
with the given sequence of tools.- Parameters
tools – Sequence of new tools to add.
destroy – If
True
all 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
, aToolBarEvent
will be generated. PassFalse
to suppress this event.redraw – If
True
, the toolbar is redrawn. PassFalse
to 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
wx
when 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
, aToolBarEvent
will be generated. Set toFalse
to suppress the event.
- __onMouseWheel(ev)¶
Called when the mouse wheel is rotated on this
FSLeyesToolBar
.Calls
__onLeftButton()
or__onRightButton()
, depending on the rotation direction.
- __onLeftButton(ev=None)¶
Called when the left toolbar button is pressed.
If the toolbar is compressed, it is scrolled to the left.
- __onRightButton(ev=None)¶
Called when the right toolbar button is pressed.
If the toolbar is compressed, it is scrolled to the right.
- __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.
- __annotations__ = {}¶
- __module__ = 'fsleyes.toolbar'¶
- fsleyes.toolbar.EVT_TOOLBAR_EVENT = <MagicMock id='140604729719680'>¶
Identifier for the
ToolBarEvent
event.
- fsleyes.toolbar.ToolBarEvent = <MagicMock id='140604729719680'>¶
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='140604700006464'>)[source]¶
Bases:
__main__.docbuilder.run.<locals>.MockClass
An empty
wx.Panel
intended to be used for dividing space in aFSLeyesToolBar
.- __annotations__ = {}¶
- __module__ = 'fsleyes.toolbar'¶