[sugar] pygtk's ".defs" files, and wrapping interfaces for python extensions
Marco Pesenti Gritti
mpg
Mon Mar 5 04:54:40 EST 2007
On Sun, 2007-03-04 at 17:10 -0800, Don Hopkins wrote:
> Can somebody please tell me where I can find some documentation on the
> .defs files used by pygtk, pangocairo, etc?
> It look like that is an alternative to SWIG for integrating C code with
> Python. Is it preferred? Does it work with other languages?
> Will it save memory or work better to use that ".defs" file based
> interface generator instead of SWIG?
>
There is no good documentation that I know about. I think there is some
outdated article you can find about in the Documentation section of
www.pygtk.org.
You can generate .defs from headers using pygtk/codegen/h2def.py. You
can also have a look to the auto* machinery we are using in
sugar/lib/python.
I don't know much about swig but I think pygtk codegen is definitely
preferred when you are wrapping gobjects.
> I'm trying to figure out how best to integrate poppler into Python, and
> pass a Cairo context into it (which was wrapped by pycairo), so it can
> go to town drawing PDF through Cairo.
I'd definitely use pygtk codegen for poppler.
> And it seems that one way to do that might be to add it into pygtk's
> cairo/pango interface, or into pycairo, but I don't know the politics
> involved in that, or if it's easier to make a separate project for poppler.
> Any suggestions please? Thanks a lot!
What about just creating a project with python bindings for poppler? The
poppler glib API has already a way to draw to a cairo context, just
wrapping this should be enough.
See this on how to use the cairo_t type with pygtk codegen:
http://svn.mugshot.org/dumbhippo/trunk/client/canvas/python/
(arg-types.py in particular)
Marco
More information about the Sugar-devel
mailing list