[PyQt] Python callback in SIP

MD marco.dinacci at gmail.com
Fri Jun 12 15:03:47 BST 2009


Hi,

> To get hold of the Python object that wraps param use sipConvertFromType().
> You will need to read the section in the docs about accessing the API when
> embedding.

I'm stuck again, I have this code now in a sip file:

class A;
class B : A {
public:
    B();
    void foo(Bar &b) ;
%MethodCode
PyObject *obj = sipConvertFromType(sipCpp, sipType_B, NULL);
PyObject *pyBar = sipConvertFromType(*b, sipType_Bar);
PyObject *result =
PyObject_CallMethodObjArgs(obj,PyString_FromString("foo"), pyBar,
NULL);
%End
}

The result is:

_test.sip: In function 'PyObject* meth_B_foo(PyObject*, PyObject*)':
_test.sip:41: error: 'sipType_B was not declared in this scope
_test.sip:41: error: 'sipConvertFromType' was not declared in this scope
_test.sip:42: error: 'b' was not declared in this scope
_test.sip:42: error: 'sipType_Bar' was not declared in this scope
error: command 'i686-unknown-linux-gnu-gcc' failed with exit status 1

I tried also in other ways, for instance by calling a global function
from within the %MethodCode% directive but I had other problems.

I guess I'm not using the right approach though I don't see any other
way, any help ?

MD


More information about the PyQt mailing list