[Qgis-developer] Python bindings

Stefanie Tellex stefie10 at media.mit.edu
Wed Jul 16 14:47:37 EDT 2008

Hi Carson,

I'm not a QGIS developer, but I have submitted a couple of patches now
that add new functions to the python bindings.  Here is what I know.

The bindings are generated with SIP, a Qt tool.  The best documentation
I've found for it is here:
http://www.riverbankcomputing.com/static/Docs/sip4/sipref.html  I've
found SIP fairly intimidating, and I've made the most progress by
copying examples from functions that already have a python interface.

SIP requires templates that tell it how to convert C++ functions and
classes to python and vice versa.  The code for all that lives in the
python subdirectory in subversion.   Most of that is just specifying
wrappers for QGIS classes.  The scariest part that I've run into so far
is conversions.sip, that provides wrappers for template-based types in
the QT container classes.

The other kind of weird thing is that only the stuff in the qgis core
and gui libraries have python equivalents, and not stuff in the
application itself.  For things like building an editor in python, I had
to write native python re-implementations of classes like
qgsmaptoolcapture to draw new objects in the UI.  This wasn't too hard,
but it was annoying.  I think some of that code should be moved to the
gui library...

Thanks for contributing!  (And thanks to all the QGIS developers for
that matter.)


Carson Farmer wrote:
> Hi all (and Martin),
> Recently I was working on a plugin and wanted to use some of the 
> functions added in the latest svn, only to find that there were no 
> python bindings available for that function yet (it was QgisInferface's 
> new addDockWidget function). Then it occurred to me, is there anywhere 
> that I can look up what has and has not had bindings completed for it 
> yet? If there is, great, where is it? If not, is this something that 
> would be simple to create?
> Also, I would like to volunteer to help with the creation of python 
> bindings etc (or some other related task that currently needs 
> attention). Unfortunately, I don't have any real experience with this 
> (just python mostly), so is there some recommended documentation that 
> might help get me started?
> Cheers,
> Carson
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer

More information about the Qgis-developer mailing list