fsleyes.actions.runscript
¶
This module provides the RunScriptAction
class, which allows
the user to run a custom Python script.
The following functions are used by the RunScriptAction
, and are
available for other purposes:
Compiles and executes the given file, assumed to be a Python script.
Creates and returns two dictionaries, to be used as the
globals
andlocals
dictionaries when executing a custom FSLeyes python script.Generates some help text that can be shown at the top of an interactive FSLLeyes shell.
-
class
fsleyes.actions.runscript.
RunScriptAction
(overlayList, displayCtx, frame)[source]¶ Bases:
fsleyes.actions.base.Action
The
RunScriptAction
class is anActuion
which allows the user to run a custom Python script to control FSLeyes. The user is prompted to select a script, and then the script is compiled and exceuted.-
__init__
(overlayList, displayCtx, frame)[source]¶ Create a
RunScriptAction
.- Parameters
overlayList – The
OverlayList
.displayCtx – The top-level
DisplayContext
.overlayList – The
FSLeyesFrame
.
-
__doAction
(script=None)¶ Called when this
Action
is invoked. If thescript
argument isNone
, the user is prompted to select a script file. The script is then compiled and executed.
-
__module__
= 'fsleyes.actions.runscript'¶
-
-
fsleyes.actions.runscript.
runScript
(frame, overlayList, displayCtx, script)[source]¶ Compiles and executes the given file, assumed to be a Python script. An
Error
is raised if the script cannot be compiled or executed.