-
Notifications
You must be signed in to change notification settings - Fork 35
BALLPythonScripting
- Python code examples in the Code Library
- State of the Python bindings
- How to create a Python binding
Most of the BALL and VIEW functionalities are available through the BALLCore and VIEW Python modules, respectively. Additionally, the BALLView application allows to run Python code from the Python widget (until version 1.4) or the Jupyter plugin (since version 1.5), offering access to currently loaded systems and representations.
The BALLCore and VIEW Python modules are already included in all binary distributions and installed automatically.
With CMake, the Python bindings will be created automatically. The modules can also be built manually using the BALLCoremodule and VIEWmodule targets, respectively:
make BALLCoremodule VIEWmoduleOn Windows, the modules can be built using the BALLPython.sln solution file instead.
When using autoconf, the Python bindings need to be compiled manually.
cd source/EXTENSIONS/
make sip && make && make installIn order to use BALL Python support you need to set the following variables:
# Linux/Mac
export PYTHONPATH=<PATH to BALL libs>:<PATH to sip libs>:${PYTHONPATH}
export LD_LIBRARY_PATH=<PATH to BALL libs>:<PATH to QT libs>:<PATH to sip libs>:${LD_LIBRARY_PATH}
# Windows
set PYTHONPATH=<PATH to BALL libs>;<PATH to sip libs>;%PYTHONPATH%
set PATH=<PATH to BALL libs>;<PATH to QT libs>;<PATH to sip libs>;%PATH%Depending on your needs, you can include the BALLCore module and, optionally, the View module into your script
import BALLCore
import VIEWor
from BALLCore import *
from VIEW import *You can find some example Python code snippets and scripts in the CodeLibrary.
As a rule of thumb all BALL classes are equally named in C++ and Python. Thus beeing aware of the special Python syntax the BALL web documentation can be used for Python as well.
Example code can be found in the Code Library and in the doc/examples/PYTHON (BALL 1.5 and later) or source/EXAMPLES/PYTHON (before BALL 1.5) directories, respectively.