[PyKDE] Help!! beginner's question

Jim Bublitz jbublitz at nwinternet.com
Tue Sep 30 18:50:00 BST 2003


On Tuesday September 30 2003 06:21, you wrote:
> I want to use python as my GUI to load a 3D
> volume(vtkImageData), and use a pointer to pass this image
> data to my own C++ class. My question is I don't know how to
> communicate between python and C++. Is there any example that
> I can start from ?
> Thanks a lot !!!!!!

I'm not sure if this is sip/PyQt related or not. If you just want 
information on general Python/C or C++ interfacing, Mark Lutz' 
"Programming Python" book has a good section (the book is 
becoming outdated, but that section is still reasonably current 
and worth the price of the book in my opinion). You can also 
look at the Python docs for the "Python/C API" and "Extending 
and Embedding". You'd get better answers to questions in that 
area on comp.lang.python.

If your application involves sip-based bindings, the only example 
I know of at the moment is pykpanelapplet.cpp in the 
pykpanelapplet/ directory in PyKDE (you'll need PyKDE-3.8rc2 
from http://www.sourceforge.net/projects/pykde - it's not in the 
3.7 release). Most of the code won't help you much, but look at 
the sipMapCppToSelf and sipForceConvertTo_<class> calls - those 
use sip conversion functions to pass objects between C++ and 
Python. Those are called from the C++ side - I don't know of any 
way to do it from the Python side, other then converting your 
C++ class to a Python module, either as an independent module or 
using sip.

Jim




More information about the PyQt mailing list