fsleyes.layouts¶
This module provides functions for managing layouts - stored view and
control panel layouts for FSLeyes. Layouts may be persisted using the
settings module. A few layouts are also built in, and are
defined in the BUILT_IN_LAYOUTS dictionary.
Note
Prior to FSLeyes 0.24.0, layouts were called perspectives.
The layouts module provides the following functions. These are intended
for use by the FSLeyesFrame, but can be used in other ways too:
Returns a list containing the names of all saved layouts. |
|
Load the named layout, and apply it to the given |
|
Applies the given serialised layout string to the given |
|
Serialises the layout of the given |
|
Deletes the named layout. |
|
Serialises the layout of the given |
|
Deserialises a layout string which was created by the |
A layout defines a layout for a FSLeyesFrame. It specifies the
type and layout of one or more views (defined in the views module)
and, within each view, the type and layout of one or more controls (defined
in the controls module). See the fsleyes documentation for
an overview of views and controls.
All of this information is stored as a string - see the
serialiseLayout() function for details on its storage format.
-
fsleyes.layouts.getAllLayouts()[source]¶ Returns a list containing the names of all saved layouts. The returned list does not include built-in layouts - these are accessible in the
BUILT_IN_LAYOUTSdictionary.
-
fsleyes.layouts.loadLayout(frame, name, **kwargs)[source]¶ Load the named layout, and apply it to the given
FSLeyesFrame. Thekwargsare passed through to theapplyLayout()function.
-
fsleyes.layouts.applyLayout(frame, name, layout, message=None)[source]¶ Applies the given serialised layout string to the given
FSLeyesFrame.- Parameters
frame – The
FSLeyesFrameinstance.name – The layout name.
layout – The serialised layout string.
message – A message to display (using the
statusmodule).
-
fsleyes.layouts.saveLayout(frame, name)[source]¶ Serialises the layout of the given
FSLeyesFrameand saves it as a layout with the given name.
-
fsleyes.layouts.serialiseLayout(frame)[source]¶ Serialises the layout of the given
FSLeyesFrame, and returns it as a string.Note
- This function was written against wx.lib.agw.aui.AuiManager as
it exists in wxPython 3.0.2.0.
FSLeyes uses a hierarchy of
wx.lib.agw.aui.AuiManagerinstances for its layout - theFSLeyesFrameuses anAuiManagerto lay outViewPanelinstances, and each of theseViewPanelsuse their ownAuiManagerto lay out control panels.The layout for a single
AuiManagercan be serialised to a string via theAuiManager.SavePerspectiveandAuiManager.SavePaneInfomethods. One of these strings consists of:A name, ‘layout1’ or ‘layout2’, specifying the AUI version (this will always be at least ‘layout2’ for FSLeyes).
A set of key-value set of key-value pairs defining the top level panel layout.
A set of key-value pairs for each pane, defining its layout. the
AuiManager.SavePaneInfomethod returns this for a single pane.
These are all encoded in a single string, with the above components separated with ‘|’ characters, and the pane-level key-value pairs separated with a ‘;’ character. For example:
layout2|key1=value1|name=Pane1;caption=Pane 1| name=Pane2;caption=Pane 2|doc_size(5,0,0)=22|
This function queries each of the AuiManagers, and extracts the following:
A layout string for the
FSLeyesFrame.A string containing a comma-separated list of
ViewPanelclass names, in the same order as they are specified in the frame layout string.For each
ViewPanel:A layout string for the
ViewPanelA string containing a comma-separated list of control panel class names, in the same order as specified in the
ViewPanellayout string.
Each of these pieces of information are then concatenated into a single newline separated string.
-
fsleyes.layouts.deserialiseLayout(layout)[source]¶ Deserialises a layout string which was created by the
serialiseLayout()string.- Returns
A tuple containing the following:
A list of
ViewPanelclass types - the children of theFSLeyesFrame.An
auilayout string for theFSLeyesFrameA list of lists, one for each
ViewPanel, with each list containing a collection of control panel class types - the children of the correspondingViewPanel.A list of strings, one
auilayout string for eachViewPanel.A list of dictionaries, one for each
ViewPanel, containing property{name : value}pairs to be applied to theViewPanel.A list of dictionaries, one for each
ViewPanel, containing property{name : value}pairs to be applied to theSceneOptsinstance associated with theViewPanel. If theViewPanelis not aCanvasPanel, the dictionary will be empty.
-
fsleyes.layouts._addToLayoutList(layout)[source]¶ Adds the given layout name to the list of saved layouts.
-
fsleyes.layouts._removeFromLayoutList(layout)[source]¶ Removes the given layout name from the list of saved layouts.
-
fsleyes.layouts._addControlPanel(viewPanel, panelType)[source]¶ Adds a control panel to the given
ViewPanel.- Parameters
viewPanel – A
ViewPanelinstance.panelType – A control panel type.
-
fsleyes.layouts._getPanelProps(panel)[source]¶ Creates and returns two dictionaries, containing properties of the given
ViewPanel(and its associatedSceneOptsinstance, if it is aCanvasPanel), which are to be saved as part of a seriaised FSLeyes layout. The properties to be saved are listed in theVIEWPANEL_PROPSdictionary.