fsleyes.actions.loadoverlay
¶
This module provides the LoadOverlayAction
, which allows the user
to load overlay files into the OverlayList
.
This module also provides a collection of standalone functions which can be called directly:
makeWildcard |
Returns a wildcard string for use in a file dialog, to limit the the displayed file types to supported overlay file types. |
loadOverlays |
Loads all of the overlays specified in the sequence of files contained in paths . |
loadImage |
Called by the loadOverlays() function. |
interactiveLoadOverlays |
Convenience function for interactively loading one or more overlays. |
Finally, this module provides a singleton RecentPathManager
instance
called recentPathManager
, which can be registered with to be notified
when new files have been loaded.
-
class
fsleyes.actions.loadoverlay.
LoadOverlayAction
(overlayList, displayCtx, frame)¶ Bases:
fsleyes.actions.base.Action
The
LoadOverlayAction
allows the user to add files to theOverlayList
.-
__init__
(overlayList, displayCtx, frame)¶ Create a
LoadOverlayAction
.Parameters: - overlayList – The
OverlayList
. - displayCtx – The
DisplayContext
. - frame – The
FSLeyesFrame
.
- overlayList – The
-
_LoadOverlayAction__loadOverlay
()¶ Calls
interactiveLoadOverlays()
.If overlays were added, updates the
DisplayContext.selectedOverlay
accordingly.If
DisplayContext.autoDisplay
isTrue
, uses theautodisplay
module to configure the display properties of each new overlay.
-
__module__
= 'fsleyes.actions.loadoverlay'¶
-
-
fsleyes.actions.loadoverlay.
makeWildcard
(allowedExts=None, descs=None)¶ Returns a wildcard string for use in a file dialog, to limit the the displayed file types to supported overlay file types.
-
fsleyes.actions.loadoverlay.
loadOverlays
(paths, loadFunc='default', errorFunc='default', saveDir=True, onLoad=None, inmem=False, blocking=False)¶ Loads all of the overlays specified in the sequence of files contained in
paths
.Note
The overlays are loaded asynchronously via
idle.idle()
. Use theonLoad
argument if you wish to be notified when the overlays have been loaded.Parameters: - loadFunc – A function which is called just before each overlay
is loaded, and is passed the overlay path. The default
load function uses the
status
module to display the name of the overlay currently being loaded. Pass inNone
to disable this default behaviour. - errorFunc – A function which is called if an error occurs while
loading an overlay, being passed the name of the
overlay, and either the
Exception
which occurred, or a string containing an error message. The default function pops up awx.MessageBox
with an error message. Pass inNone
to disable this default behaviour. - saveDir – If
True
(the default), the directory of the last overlay in the list ofpaths
is saved, and used later on as the default load directory. - onLoad – Optional function to call when all overlays have been loaded. Must accept one parameter - a list containing the overlays that were loaded.
- inmem – If
True
, allImage
overlays are force-loaded into memory. Otherwise, large compressed files may be kept on disk. Defaults toFalse
. - blocking – Defaults to
False
. IfTrue
, overlays are loaded immediately (and theonLoad
function is called directly. Otherwise, overlays and theonLoad
are loaded loaded/called on theidle.idle()
loop.
Returns: If
blocking is False
(the default), returnsNone
. Otherwise returns a list containing the loaded overlay objects.- loadFunc – A function which is called just before each overlay
is loaded, and is passed the overlay path. The default
load function uses the
-
fsleyes.actions.loadoverlay.
loadImage
(dtype, path, inmem=False)¶ Called by the
loadOverlays()
function. Loads an overlay which is represented by anImage
instance, or a sub-class ofImage
. Depending upon the image size, the data may be loaded into memory or kept on disk, and the initial image data range may be calculated from the whole image, or from a sample.Parameters: - dtype – Overlay type (
Image
, or a sub-class ofImage
). - path – Path to the overlay file.
- inmem – If
True
,Image
overlays are loaded into memory.
- dtype – Overlay type (
-
fsleyes.actions.loadoverlay.
interactiveLoadOverlays
(fromDir=None, dirdlg=False, **kwargs)¶ Convenience function for interactively loading one or more overlays.
Pops up a file dialog prompting the user to select one or more overlays to load.
Parameters: - fromDir – Directory in which the file dialog should start. If
None
, the most recently visited directory (via this function) is used, or a directory from An already loaded overlay, or the current working directory. - dirdlg – Use a directory chooser instead of a file dialog.
- kwargs – Passed through to the
loadOverlays()
function.
Raises: - ImportError – if
wx
is not present. - RuntimeError – if a
wx.App
has not been created.
- fromDir – Directory in which the file dialog should start. If
-
class
fsleyes.actions.loadoverlay.
RecentPathManager
(*args, **kwargs)¶ Bases:
__main__.MockClass
The
RecentPathManager
is a simple class which provides access to a list of recently loaded files, and can notify registered listeners when that list changes. See therecentPathManager
singleton instance.-
recordPath
(path)¶ Adds the given
path
to the recent files list.
-
listRecentPaths
()¶ Returns a list of recently loaded files.
-
__module__
= 'fsleyes.actions.loadoverlay'¶
-
-
fsleyes.actions.loadoverlay.
recentPathManager
= <fsleyes.actions.loadoverlay.RecentPathManager object>¶ A
RecentPathManager
instance which gets updated by theloadOverlays()
function whenever a new path is loaded. Register as a listener on this instance if you want to be notified of changes to the recent paths list.