-
Notifications
You must be signed in to change notification settings - Fork 32
CreatePythonBinding
One of the core features of BALL are its Python bindings, that enable users of for example BALLView to directly call library routines from a graphical front-end or enable developers to write small utility scripts. In order for this to work a so called language binding between C++ and Python must be created. For this purpose BALL uses the sip software package that automates the most ugly parts of this business. However if you just created a new class or modified an existing one, sip needs to know about the changes you made. The following sections explain how this can be done:
The following folders are important if you want to create a new Python binding:
- /ball/source/PYTHON: parent folder of all .sip files
- /ball/source/PYTHON/EXTENSIONS/BALL: all .sip files related to the core BALL library
- /ball/source/PYTHON/EXTENSIONS/VIEW: all .sip files related to the BALLView library
Create your new python binding in one of the subfolders ../BALL or ../VIEW. It's usually a good idea to look at other .sip files in these folders to get an idea how to deal with sip. \ Additionally, some tutorials concerning sip can be found online. [1,2]
After creating your new binding, you have to link it to make it visible to your Python interface. This is done by including the newly created sip file either in \ /ball/source/PYTHON/EXTENSIONS/BALL/BALLCore.sip or \ /ball/source/PYTHON/EXTENSIONS/VIEW/VIEW.sip, \ depending on whether it is related to the BALL or the BALLView library. \ \ Including your file is done by looking for the best fitting place within these files and writing %Include yourNewSipFile.sip. \
After executing all the steps mentioned above, all that is left to do for you is to compile everything (by typing "make") or just the module you modified (by typing "make modifiedModule") again. \ "make targets" will present you a list of all possible targets to compile.
[1]: http://www.commandprompt.com/community/pyqt/x8887.htm \ [2]: http://pyqt.sourceforge.net/Docs/sip4/