[PyQt] Python callback in SIP

MD marco.dinacci at gmail.com
Fri Jun 12 15:38:45 BST 2009


Phil,

> So why are you now using .sip files? I though you were embedding in a C++
> application, not generating a Python module.

Well I guess I didn't explain myself very clearly...I'm sorry.
I'm wrapping a C++ library in order to generate a Python module. When
using the C++ library, a developer can subclass A (which is an
interface) and override the foo method, then another object of another
class will automaticall call foo on the overridden object.
The idea with the Python bindings is that the developer create a
Python class extending from the wrapped A class, create a foo method
and then the C++ code automatically call it. In order for this to work
I have to subclass A in C++ (let's call it B) and in its foo method
somehow call the "equivalent" python foo method. Then I'll wrap B with
SIP and I'll extend it in Python.
I don't know if this is the best approach but it's what I've used when
wrapping the library using the Python C API and Cython. I'm now trying
to wrap it with SIP in order to compare the various wrapping
technologies, but for now SIP is the one that is causing me more
headaches.

I hope it's clear, it's not so easy to explain it :)

MD


More information about the PyQt mailing list