Python Scripting via Voreen's Python Module

The Python module integrates the Python3/C API into Voreen and enables Python bindings for some basic Voreen functions.
Sample scripts are already included in modules/python/scripts and showcase some common applications. Essentially, any Python3 script can be executed by VoreenVE and the output will be forwarded to the module's console. The scripting tool is available from the menu bar: Tools -> Python Scripting.

Scripting


Both VoreenCore and VoreenQt define Python modules which can be imported using

import voreen   # Core functionality
import voreenqt # Qt specific functionality

voreen.info()   # print overview about voreen core python module
voreenqt.info() # print overview about voreen qt python module

processorID = "Canvas"      # define processor ID
propertyID  = "canvasSize"  # define property ID

dimensions = voreen.getPropertyValue(canvasID, propertyID) # retrieve property value using voreen module
message = "%dx%d" % (dimensions[0], dimensions[1])         # execute arbitrary python code
voreenqt.messageBox("Canvas size: " + message)             # print message using voreenqt module
voreen.setPropertyValue(canvasID, propertyID, [512, 512])  # set new property value using voreen module



For further information please refer to the module overview by calling info() on the respective Voreen module.


Headless


If a script needs to be executed without the visual front-end or just no graphical front-end is available, voreentool can be used to execute a python script from the command line. Execute voreentool, e.g., by using


./voreentool -w someworkspace.vws --script somescript.py


Misc.


On Windows, an embedded version of Python3 is bundled with the Voreen executable, providing only basic features and modules. This version can be extended and modified by adding scripts and modules to modules/python/ext/Python37/lib. Using Linux, however, the system's Python3 will be used for voreen which was available during compilation. Currently, the AppImages of voreen do not contain the Python module. It is thus necessary to build Voreen and activate the Python module in CMake.

Institut für Informatik
Einsteinstr. 62
· 48149 Münster
Fax: +49 251 83-33755
E-Mail: