fsleyes.actions.saveoverlay

This module provides the SaveOverlayAction, which allows the user to save the currently selected overlay. A couple of standalone functions are defined in this module, which do the real work:

saveOverlay Saves the currently selected overlay (only if it is a Image), by a call to Image.save().
doSave Called by saveOverlay().
checkOverlaySaveState Returns True if all (compatible) overlays are saved to disk, False if there are any overlays with unsaved changes.
class fsleyes.actions.saveoverlay.SaveOverlayAction(overlayList, displayCtx, frame)[source]

Bases: fsleyes.actions.base.Action

The SaveOverlayAction allows the user to save the currently selected overlay, if it has been edited, or only exists in memory.

__init__(overlayList, displayCtx, frame)[source]

Create a SaveOverlayAction.

Parameters:
destroy()[source]

Removes listeners from the DisplayContext and OverlayList, and calls Action.destroy().

_SaveOverlayAction__overlaySaveStateChanged(*a)

Called when the Image.saved property of the currently selected overlay changes. Enables/disables this SaveOverlayAction accordingly.

This is only applicable if the current overlay is a Image - see the __selectedOverlayChanged() method.

_SaveOverlayAction__saveOverlay()

Called when this Action is executed. Calls saveOverlay() with the currently selected overlay.

_SaveOverlayAction__selectedOverlayChanged(*a)

Called when the selected overlay, or overlay list changes.

If the overlay is a Image, and it has unsaved changes, this action is enabled; otherwise it is disabled.

__module__ = 'fsleyes.actions.saveoverlay'
fsleyes.actions.saveoverlay.saveOverlay(overlay, display=None)[source]

Saves the currently selected overlay (only if it is a Image), by a call to Image.save(). If a display is provided, the Display.name may be updated to match the new overlay file name.

Parameters:
  • overlay – The Image overlay to save
  • display – The Display instance associated with the overlay.
fsleyes.actions.saveoverlay.doSave(overlay, path=None)[source]

Called by saveOverlay(). Tries to save the given overlay to the given path, and shows an error message if something goes wrong. Returns True if the save was successful, False otherwise.

fsleyes.actions.saveoverlay.checkOverlaySaveState(overlayList, displayCtx)[source]

Returns True if all (compatible) overlays are saved to disk, False if there are any overlays with unsaved changes.