[PyKDE] Wrapping a custom Model into Python

David Boddie david at boddie.org.uk
Sun Aug 20 16:05:55 BST 2006


On Wed Aug 16 21:33:34 MEST 2006, Andreas Pakulat wrote:

> On 16.08.06 15:14:18, Tobias Rundström wrote:
> > What is the best practice of wrapping a custom QAbstractItemModel into
> > PyQt? I developed a ItemModel that I want to use in a C++ program as
> > well as in my Python program, the best way seems to be to write it in
> > C++ and then wrap it into PyQt, this allows sharing the model code. What
> > is the best way of doing this?
> 
> I think you're looking for sip and it's documentation. That's what is
> used to build PyQt and thus it shouldn't be too hard to use for a code
> model. I'm not sure but you might need to put the model into a shared
> library.

Depending on the way it's going to be used, it could either be create as
a separate shared library, or just compiled in with the Python-specific
code for the shared library module.

Using SIP is the subject of an appendix in "GUI Programming with Python":

  http://www.commandprompt.com/community/pyqt/a8834

The SIP Reference Guide is available on the Riverbank Web site:

  http://www.riverbankcomputing.com/Docs/sip4/sipref.html

David




More information about the PyQt mailing list