[sugar] pygtk's ".defs" files, and wrapping interfaces for python extensions

Don Hopkins dhopkins at DonHopkins.com
Mon Mar 5 05:45:41 EST 2007


Very interesting -- I'll read more about the pygtk codegen stuff. Thanks 
for the pointers!

I tried to make my own project by copying the pycairo directory and 
using it as a template, but that has hand-written Python interfaces 
instead of using pygtk codegen, and the gnu automake configuration stuff 
is being difficult and making my brain hurt.

I took a look at the hippo canvas stuff, and it looks very nifty, and I 
think that might be a good way to integrate the Poppler PDF library with 
Cairo.

I think I could just make a canvas object like the hippo image object, 
that reads from PDF files instead, and calls Poppler to render into the 
Cairo context.
Maybe I could just add it to the hippo project without making my own 
project, and use the canvas image object as an example of how to wrap 
the interface.
Hippo canvas uses the pygtk codegen to generate the interfaces, so 
that's a point in its favor.

Is the hippo canvas code set up to be extend with separate projects, or 
is it easiest to just add new canvas components to the hippo project 
itself?
I guess it would be easier for me to just add some new stuff to an 
existing project, that way I could avoid messing with the configuration 
stuff.

So is Hippo the cat's meow, and does Poppler taste like chicken? (Sorry 
to mix animal metaphores...)

Thanks for the help!

    -Don



Marco Pesenti Gritti wrote:
> 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
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.laptop.org/pipermail/sugar/attachments/20070305/6acbd706/attachment.html


More information about the Sugar mailing list