fsleyes.panel
This module provides the FSLeyesPanel
class.
A FSLeyesPanel
object is a wx.Panel
which provides some sort
of view of a collection of overlay objects, contained within an
OverlayList
. The FSLeyesPanel
is the base class for all GUI
panels in FSLeyes - see also the ViewPanel
and ControlPanel
classes.
FSLeyesPanel
instances are also ActionProvider
instances - any
actions which are specified in the class definitions may (or may not) be
exposed to the user. Furthermore, any display configuration options which
should be made available available to the user can be added as
PropertyBase
attributes of the FSLeyesPanel
subclass.
Note
FSLeyesPanel
instances are usually displayed within a
FSLeyesFrame
, but they can be used on their own
as well. You will need to create, or need references to,
an OverlayList
and a DisplayContext
.
For example:
import fsleyes.overlay as ovl
import fsleyes.displaycontext as dc
import fsleyes.views.orthopanel as op
overlayList = ovl.OverlayList()
displayCtx = dc.DisplayContext(overlayList)
# the parent argument is some wx parent
# object such as a wx.Frame or wx.Panel.
# Pass in None as the FSLeyesFrame
orthoPanel = op.OrthoPanel(parent,
overlayList,
displayCtx,
None)
- class fsleyes.panel._FSLeyesPanel(overlayList, displayCtx, frame, kbFocus=False)[source]
Bases:
fsleyes.actions.ActionProvider
,__main__.docbuilder.run.<locals>.MockClass
The
_FSLeyesPanel
is the base class for theFSLeyesPanel
and theFSLeyesToolBar
.A
_FSLeyesPanel
has the following methods and properties, available for use by subclasses:Returns a unique name associated with this
_FSLeyesPanel
.Returns the
FSLeyesFrame
which created this_FSLeyesPanel
.Set the keyboard (tab, shift+tab) navigation order to the given list of controls, assumed to be children of this
_FSLeyesPanel
.This method must be called by whatever is managing this
_FSLeyesPanel
when it is to be closed/destroyed.Returns
True
if a call todestroy()
has been made,False
otherwise.Note
When a
_FSLeyesPanel
is no longer required, thedestroy()
method must be called!- __init__(overlayList, displayCtx, frame, kbFocus=False)[source]
Create a
_FSLeyesPanel
.- Parameters
overlayList – A
OverlayList
instance.displayCtx – A
DisplayContext
instance.frame – The
FSLeyesFrame
that created this_FSLeyesPanel
. May beNone
.kbFocus – If
True
, a keyboard event handler is configured to interceptTab
andShift+Tab
keyboard events, to shift focus between a set of child widgets. The child widgets to be included in the navigation can be specified with thesetNavOrder()
method.
Set the keyboard (tab, shift+tab) navigation order to the given list of controls, assumed to be children of this
_FSLeyesPanel
.
- property name
Returns a unique name associated with this
_FSLeyesPanel
.
- property frame
Returns the
FSLeyesFrame
which created this_FSLeyesPanel
. May beNone
, if this panel was not created by aFSLeyesFrame
.
- destroy()[source]
This method must be called by whatever is managing this
_FSLeyesPanel
when it is to be closed/destroyed.It seems to be impossible to define a single handler (on either the
wx.EVT_CLOSE
and/orwx.EVT_WINDOW_DESTROY
events) which handles both cases where the window is destroyed (in the process of destroying a parent window), and where the window is explicitly closed by the user (e.g. when embedded as a page in a Notebook).This issue is probably caused by my use of the AUI framework for layout management, as the AUI manager/notebook classes do not seem to call close/destroy in all cases. Everything that I’ve tried, which relies upon
EVT_CLOSE
/EVT_WINDOW_DESTROY
events, inevitably results in the event handlers not being called, or in segmentation faults (presumably due to double-frees at the C++ level).Subclasses which need to perform any cleaning up when they are closed may override this method, and should be able to assume that it will be called. So this method must be called by managing code when a panel is deleted.
Overriding subclass implementations must call this base class method, otherwise memory leaks will probably occur, and warnings will probably be output to the log (see
__del__()
). This implememtation should be called after the subclass has performed its own clean-up, as this method expliciltly clears theoverlayList
anddisplayCtx
references (viaActionProvider.destroy()
).
- _FSLeyesPanel__onCharHook(ev)
Called on
EVT_CHAR_HOOK
events. Intercepts tab key presses, to force an explicit keyboard navigation ordering.
- __annotations__ = {}
- __module__ = 'fsleyes.panel'
- class fsleyes.panel.FSLeyesPanel(parent, overlayList, displayCtx, frame, *args, **kwargs)[source]
Bases:
fsleyes.panel._FSLeyesPanel
,__main__.docbuilder.run.<locals>.MockClass
The
FSLeyesPanel
is the base class for all view and control panels in FSLeyes. See thefsleyes
documentation for more details.See also the
ViewPanel
andControlPanel
classes.- __metaclass__ = <MagicMock name='mock.siplib.wrappertype' id='140735755285312'>
- __init__(parent, overlayList, displayCtx, frame, *args, **kwargs)[source]
Create a
_FSLeyesPanel
.- Parameters
overlayList – A
OverlayList
instance.displayCtx – A
DisplayContext
instance.frame – The
FSLeyesFrame
that created this_FSLeyesPanel
. May beNone
.kbFocus – If
True
, a keyboard event handler is configured to interceptTab
andShift+Tab
keyboard events, to shift focus between a set of child widgets. The child widgets to be included in the navigation can be specified with thesetNavOrder()
method.
- __annotations__ = {}
- __module__ = 'fsleyes.panel'