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 the FSLeyesPanel and the FSLeyesToolBar.

A _FSLeyesPanel has the following methods and properties, available for use by subclasses:

name

Returns a unique name associated with this _FSLeyesPanel.

frame

Returns the FSLeyesFrame which created this _FSLeyesPanel.

setNavOrder

Set the keyboard (tab, shift+tab) navigation order to the given list of controls, assumed to be children of this _FSLeyesPanel.

destroy

This method must be called by whatever is managing this _FSLeyesPanel when it is to be closed/destroyed.

destroyed

Returns True if a call to destroy() has been made, False otherwise.

Note

When a _FSLeyesPanel is no longer required, the destroy() 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 be None.

  • kbFocus – If True, a keyboard event handler is configured to intercept Tab and Shift+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 the setNavOrder() method.

setNavOrder(children)[source]

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 be None, if this panel was not created by a FSLeyesFrame.

property _overlayList

MagicMock is a subclass of Mock with default implementations of most of the magic methods. You can use MagicMock without having to configure the magic methods yourself.

If you use the spec or spec_set arguments then only magic methods that exist in the spec will be created.

Attributes and the return value of a MagicMock will also be MagicMocks.

property _displayCtx

MagicMock is a subclass of Mock with default implementations of most of the magic methods. You can use MagicMock without having to configure the magic methods yourself.

If you use the spec or spec_set arguments then only magic methods that exist in the spec will be created.

Attributes and the return value of a MagicMock will also be MagicMocks.

property _name

MagicMock is a subclass of Mock with default implementations of most of the magic methods. You can use MagicMock without having to configure the magic methods yourself.

If you use the spec or spec_set arguments then only magic methods that exist in the spec will be created.

Attributes and the return value of a MagicMock will also be MagicMocks.

getName = <MagicMock name='mock.utils.deprecated.deprecated()()' id='4396606371632'>
getFrame = <MagicMock name='mock.utils.deprecated.deprecated()()' id='4396606371632'>
getDisplayContext = <MagicMock name='mock.utils.deprecated.deprecated()()' id='4396606371632'>
getOverlayList = <MagicMock name='mock.utils.deprecated.deprecated()()' id='4396606371632'>
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/or wx.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 the overlayList and displayCtx references (via ActionProvider.destroy()).

property destroyed

Returns True if a call to destroy() has been made, False otherwise.

__del__()[source]

If the destroy() method has not been called, a warning message is logged.

_FSLeyesPanel__onCharHook(ev)

Called on EVT_CHAR_HOOK events. Intercepts tab key presses, to force an explicit keyboard navigation ordering.

__module__ = 'fsleyes.panel'
fsleyes.panel.FSLeyesPanelMeta

alias of builtins.type

fsleyes.panel.FSLeyesPanelBase

alias of __main__.docbuilder.run.<locals>.MockClass

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 the fsleyes documentation for more details.

See also the ViewPanel and ControlPanel classes.

__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 be None.

  • kbFocus – If True, a keyboard event handler is configured to intercept Tab and Shift+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 the setNavOrder() method.

__module__ = 'fsleyes.panel'
class fsleyes.panel.FSLeyesSettingsPanel(*args, **kwargs)[source]

Bases: fsleyes.panel.FSLeyesPanel

The FSLeyesSettingsPanel is deprecated - it has been replaced with the controls.controlpanel.SettingsPanel.

__module__ = 'fsleyes.panel'
__init__ = <MagicMock name='mock.utils.deprecated.deprecated()()' id='4396606371632'>
getWidgetList()[source]