fsleyes.views.viewpanel

This module provides the ViewPanel class, which is the base-class for all of the FSLeyes view panels. See the fsleyes package documentation for more details.

class fsleyes.views.viewpanel.ViewPanel(parent, overlayList, displayCtx, frame)[source]

Bases: fsleyes.panel.FSLeyesPanel

The ViewPanel class is the base-class for all FSLeyes views.

A ViewPanel displays some sort of view of the overlays in an OverlayList. The settings for a ViewPanel are defined by a DisplayContext instance.

Panels and controls

A ViewPanel class uses a wx.lib.agw.aui.AuiManager to lay out its children. A ViewPanel has one central panel, which contains the primary view; and may have one or more secondary panels, which contain controls - see the controls package. The centre panel can be set via the centrePanel() property, and secondary panels can be added/removed to/from with the togglePanel() method. The current state of a secondary panel (i.e. whether one is open or not) can be queried with the isPanelOpen() method, and existing secondary panels can be accessed via the getPanel() method. Secondary panels must be derived from either the ControlPanel or ControlToolBar base-classes.

Profiles

Some ViewPanel classes have relatively complex mouse and keyboard interaction behaviour (e.g. the OrthoPanel and LightBoxPanel). The logic defines this interaction is provided by a Profile instance, and is managed by a ProfileManager. Some ViewPanel classes have multiple interaction profiles - for example, the OrthoPanel has a view profile, and an edit profile. The current interaction profile can be changed with the profile property, and can be accessed with the getCurrentProfile() method. See the profiles package for more information on interaction profiles.

Programming interface

The following methods are available on a Viewpanel for programmatically controlling its display and layout:

togglePanel

Add/remove the secondary panel of the specified type to/from this ViewPanel.

isPanelOpen

Returns True if a panel of type panelType is open, False otherwise.

getPanel

If an instance of panelType exists, it is returned.

getPanels

Returns a list containing all control panels currently shown in this ViewPanel.

getTools

This method should be overridden by sub-classes (if necessary), and should return any action methods which should be added to the FSLeyesFrame Tools menu.

removeFromFrame

Remove this ViewPanel from the FSLeyesFrame.

removeAllPanels

Remove all control panels from this ViewPanel.

getPanelInfo

Returns the AuiPaneInfo object which contains information about the given control panel.

auiManager

Returns the wx.lib.agw.aui.AuiManager object which manages the layout of this ViewPanel.

profile = <MagicMock name='mock.Choice()' id='3030895104'>

The current interaction profile for this ViewPanel.

__init__(parent, overlayList, displayCtx, frame)[source]

Create a ViewPanel. All arguments are passed through to the FSLeyesPanel constructor.

destroy()[source]

Removes some property listeners, destroys all child panels, destroys the ProfileManager, and AuiManager, and calls FSLeyesPanel.destroy().

initProfile()[source]

Must be called by subclasses, after they have initialised all of the attributes which may be needed by their associated Profile instances.

getCurrentProfile()[source]

Returns the Profile instance currently in use.

getCentrePanel = <MagicMock name='mock.utils.deprecated.deprecated()()' id='3031103328'>
property centrePanel

Returns the primary (centre) panel on this ViewPanel.

setCentrePanel = <MagicMock name='mock.utils.deprecated.deprecated()()' id='3031103328'>
togglePanel(panelType, *args, **kwargs)[source]

Add/remove the secondary panel of the specified type to/from this ViewPanel.

If no keyword argunents are specified, the arguments returned by the ControlMixin.defaultLayout() method are returned.

Parameters
  • panelType – Type of the secondary panel.

  • args – All positional arguments are passed to the panelType constructor.

  • floatPane – If True, the secondary panel is initially floated. Defaults to False.

  • floatOnly – If True, and floatPane=True, the panel will be permanently floated (i.e. it will not be dockable).

  • floatPos – If provided, and floatPane is True, specifies the location of the floating panel as (w, h) proportions between 0 and 1, relative to this view panel.

  • closeable – If False, and floatPane=True, the panel will not have a close button when it is floated.

  • location – If floatPane=False, the initial dock position of the panel - either wx.TOP, wx.BOTTOM, wx.LEFT, or wx.RIGHT. Defaults to ``wx.BOTTOM.

  • title – Title to give the control. If not provided, it is assumed that a title for panelType is in strings.titles.

  • kwargs – All other keyword arguments, are passed to the panelType constructor.

Note

The panelType type must be a sub-class of ControlPanel or ControlToolBar, which can be created like so:

panel = panelType(parent,
                  overlayList,
                  displayCtx,
                  frame,
                  *args,
                  **kwargs)

Warning

Do not define a control (a.k.a. secondary) panel constructor to accept arguments with the names floatPane, floatOnly, floatPos, closeable, or location, as arguments with those names will get eaten by this method before they can be passed to the constructor.

isPanelOpen(panelType)[source]

Returns True if a panel of type panelType is open, False otherwise.

getPanel(panelType)[source]

If an instance of panelType exists, it is returned. Otherwise None is returned.

removeAllPanels()[source]

Remove all control panels from this ViewPanel.

removeFromFrame()[source]

Remove this ViewPanel from the FSLeyesFrame.

Will raise an error if this ViewPanel is not in a FSLeyesFrame.

getPanels()[source]

Returns a list containing all control panels currently shown in this ViewPanel.

getPanelInfo(panel)[source]

Returns the AuiPaneInfo object which contains information about the given control panel.

property auiManager

Returns the wx.lib.agw.aui.AuiManager object which manages the layout of this ViewPanel.

getAuiManager = <MagicMock name='mock.utils.deprecated.deprecated()()' id='3031103328'>
getTools()[source]

This method should be overridden by sub-classes (if necessary), and should return any action methods which should be added to the FSLeyesFrame Tools menu.

_ViewPanel__auiMgrUpdate(*args, **kwargs)

Called whenever a panel is added/removed to/from this ViewPanel.

Calls the Update method on the AuiManager instance that is managing this panel.

Parameters

newPanel – Must be passed as a keyword argument. When a new panel is added, it should be passed here.

_ViewPanel__onPaneClose(ev=None, panel=None)

Called when the user closes a control (a.k.a. secondary) panel. Calls the ControlPanel.destroy/ControlToolBar.destroy method on the panel.

_ViewPanel__profileChanged(*a)

Called when the current profile property changes. Tells the ProfileManager about the change.

The ProfileManager will create a new Profile instance of the appropriate type.

__module__ = 'fsleyes.views.viewpanel'
fsleyes.views.viewpanel._AuiDockingGuide_init(self, *args, **kwargs)[source]

I am also monkey-patching the wx.lib.agw.aui.AuiDockingGuide.__init__ method, because in this instance, when running over SSH/X11, the wx.FRAME_TOOL_WINDOW style seems to result in the docking guide frames being given title bars, which is quite undesirable.

I cannot patch the entire class in the aui package, because it is used as part of a class hierarchy. So I am just patching the method.