[pygtk] How to call methods with output parameters using gobject introspection?
John Stowers
john.stowers.lists at gmail.com
Tue Mar 22 17:10:19 WST 2011
On Tue, 2011-03-22 at 21:28 +1300, Greg Ewing wrote:
> How are you supposed to call the PangoLayout.get_pixel_size()
> method using gobject introspection?
>
> The C signature is
>
> void pango_layout_get_pixel_size(
> PangoLayout *layout, int *width, int *height);
>
> Using the old Python bindings, you called it with no parameters
> and it returned a 2-tuple.
>
> But the gi version seems to expect 2 parameters and returns
> None. What's more, it seems to expect them to be *numbers*.
>
> Since most numbers in Python are immutable, how the heck
> is this supposed to work?
In general we try to be compatible with PyGTK, if the syntax is
different to what used to work then it is a bug. But looking at
http://git.gnome.org/browse/pango/tree/pango/pango-layout.c#n2725
Shows the parameters, correctly, annotated with (out) which means that
it should just work. In some cases we do write python shims (overrides)
to make the introspection API identical to the old pygtk API, but it
looks like it was not necessary in this case
http://git.gnome.org/browse/pygobject/tree/gi/overrides/Pango.py#n40
So, no idea why it is not magically working for you. What versions of
everything are you using?
John
More information about the pygtk
mailing list