开发者

Create Gtk.Atom with PyGobject Introspection and Gtk+3

Context:

There was once a post on preventing window overlap with Gtk+2.x Recent changes in Gtk+3 have however affected the gdk_property_change() function, which has the PyGobject Introspection (hereafter referred to as PyGI) equivalent of Gdk.property_change(). In the previous SO answer the property_change arguments were of type (str, str, Gdk.PROP_MOD_*, int, data), the Gtk+3 equivalent asks instead for (GdkWindow, GdkAtom, GdkAtom, int, GdkPropMode, data, int). Passing a GdkAtom as argument rather than a string seems to be the new requirement.

Problem:

New Gd开发者_运维技巧k.Atom can be created with PyGtk with the gtk.gdk.atom_intern(str) method. The corresponding C function in the documentation is gdk_atom_intern(). There is however no such method in PyGI: a mere dir(Gtk) will return Gdk.Atom or Gdk.atom_name but no Gdk.atom_intern. The Gdk.Atom has no apparent method either. PS: it seems reading this code at line 139 that Gdk.atom_intern() would be available though.

Question:

Do you know how I could create (or find out how to create) a Gdk.Atom using PyGI with Gtk+3?

Thanks.


It might be that Gobject-Introspection picks up Gdk from Gtk+-2.0 version, so you have to force the version:

In [1]: import gi  
In [2]: gi.require_version("Gdk", "3.0")   
In [3]: from gi.repository import Gdk    
In [4]: Gdk.__path__
Out[4]: '/usr/lib64/girepository-1.0/Gdk-3.0.typelib'    
In [5]: Gdk.atom_intern
Out[5]: <function atom_intern at 0x152f140>    
In [6]: Gdk.atom_intern_static_string
Out[6]: <function atom_intern_static_string at 0x152f398>

For this to work, the gir1.2-gtk-3.0 package is needed. On Ubuntu it can be installed from repositories with sudo apt-get install gir1.2-gtk-3.0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜