[PySide] inter-object communications
John Ehresman
jpe at wingware.com
Fri Nov 8 17:17:41 CET 2013
On 11/8/13 11:01 AM, Henry Gomersall wrote:
> Ah, ok. So PySide creates a parallel class heirarchy, with methods that
> can call back into Python. Out of interest, how is this check on being a
> python implemented subclass performed? (a pointer to the relevant code
> would be awesome!).
At a high level, the code for a method named "foo" is (untested code
that omits error handling and ref counting):
C++WrapperClass::foo(args...)
{
override = PyObject_GetAttrString(pySelf, "foo");
if (override != NULL) {
result = PyObject_Call(override, args...);
return result;
}
else {
return C++BaseClass::foo(args...);
}
}
Best way to get a more detailed look (for me, at least) is to look at
the generated code. In a built PySide tree, look at
PySide/QtGui/PySide/QtGui/qwidget_wrapper.cpp in the build directory.
The QWidgetWrapper::setVisible method is the override for the
QWidget::setVisible method.
Cheers,
John
More information about the PySide
mailing list