[pygtk] pygobject documentation ?
Timo
timomlists at gmail.com
Thu Jan 12 18:46:37 WST 2012
Op 11-01-12 21:44, Jérôme schreef:
> Tue, 10 Jan 2012 18:54:07 +0100
> Timo a écrit:
>
>> You will notice a pattern: take the enumeration name, split the Gtk part
>> and rest with a dot, then leave out GTK_*_ part from the types and
>> append them to the previously splitted name.
>>
>> This approach always worked for me till now.
> This seems to extend tu Gdk.
>
> Besides, there's an exception when the stripped enum begins with a number, as
> a python variable can't begin with a number.
>
> http://developer.gnome.org/gdk3/stable/gdk3-Events.html#GdkEventType
>
> typedef enum {
> GDK_NOTHING = -1,
> GDK_DELETE = 0,
> GDK_DESTROY = 1,
> GDK_EXPOSE = 2,
> GDK_MOTION_NOTIFY = 3,
> GDK_BUTTON_PRESS = 4,
> GDK_2BUTTON_PRESS = 5,
> GDK_3BUTTON_PRESS = 6,
> [...]
> } GdkEventType;
>
> becomes
>
> /usr/share/pyshared/gi/overrides/Gdk.py
>
> class Event(Gdk.Event):
> _UNION_MEMBERS = {
> Gdk.EventType.DELETE: 'any',
> Gdk.EventType.DESTROY: 'any',
> Gdk.EventType.EXPOSE: 'expose',
> Gdk.EventType.MOTION_NOTIFY: 'motion',
> Gdk.EventType.BUTTON_PRESS: 'button',
> Gdk.EventType._2BUTTON_PRESS: 'button',<-- see the _
> Gdk.EventType._3BUTTON_PRESS: 'button',<-- see the _
> [...]
> }
>
> I had a hard type figuring that one out...
You are right, this is an exception. For people new to Python+GTK
programming, this can be confusing, but for old PyGTK developers, it is
the same behaviour as before:
>>> import gtk
>>> gtk.gdk._2BUTTON_PRESS
<enum GDK_2BUTTON_PRESS of type GdkEventType>
Cheers,
Timo
>
More information about the pygtk
mailing list