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
globalsandlocalsdictionaries 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.ActionThe
RunScriptActionclass is anActuionwhich 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
Actionis invoked. If thescriptargument 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
Erroris raised if the script cannot be compiled or executed.