Offers features for script editing and for running user scripts.
For details on user scripts, see Section 4.8, “User Scripts”
Scripting is used to implement the dynamic functionality of module user interfaces and applications (which are defined as macro modules) in MeVisLab.
Scripting is done in the context of a module. Via the script context variable of the module (ctx), access is given to the module instance itself as well as to all members of the module like fields, input/outputs, and GUI controls. This way, getting/setting field values (module parameters), connecting/disconnecting fields, implementing dynamic user interfaces, and much more can be done dynamically .
In the context of an MLABMacroModule, access to the contexts of all modules contained in the modules macro network is available (recursive descend).
For scripting in MeVisLab one can use the Python language, via an object-binding with PythonQt, an inhouse-development by MeVis.
This object-binding uses the Qt Meta Object System to find out about the MLAB object features.
For the doxygen documentation of the scripting interface, see the MeVisLab Scripting Reference.
It is possible (but not recommended) to include single line script statements in MDL script files.
Opens a command line console to type in Python code. Useful for debugging when programming user interfaces dynamically. The console is opened in the context of the current network. Access is possible to
the contexts of all modules contained in the current network
(for macro modules) to all objects of included modules in a recursive descend
If the current network is a macro network, the script console is opened in the context of the macro module. The same context is reached when opening the script console via the macro module's context menu, Debugging → Show Script Console.
Example listing in Python. The code has to be entered one line at a time, and without any indents. Make sure that the modules LocalImage and View2D exist in the current network, and that the modules have those specific instance names:
# get module context module = ctx.module("LocalImage") # set/get module field value filename = module.field("trueName").value module.field("name").value = "$(DemoDataPath)/bone.tiff" # connect fields ctx.connectField("View2D.inImage","LocalImage.outImage") # open GUI window control window = ctx.module("View2D").createWindow("Viewer") window.setTitle("HelloWorld") ctx.module("View2D").showWindow("Viewer")
The context menu of the Scripting View contains the usual commands for text editing, see also Section 4.2, “Edit Menu”.
In addition, three options are available:
Show MeVisLab Scripting Help
Opens the Scripting Reference documentation (HTML) in the default web browser.
Can be switched from the default (as defined in the Preferences) to the other script language. We recommend to stay with Python (see note above).
Clears the scripting console.
(Macro modules only) Opens the interface definition file (
.def) in the default text editor.
© 2021 MeVis Medical Solutions AG