[英]Create Gtk.Atom with PyGobject Introspection and Gtk+3
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()
. 曾经有一篇关于防止窗口与Gtk + 2.x重叠的文章。但是,最近Gtk + 3的更改影响了
gdk_property_change()
函数,该函数具有与Gdk.property_change()等效的PyGobject自省(以下称为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). 在先前的SO答案中,
property_change
参数的类型为(str,str,Gdk.PROP_MOD _ *,int,数据),Gtk + 3等效要求提供(GdkWindow,GdkAtom,GdkAtom,int,GdkPropMode,data,int)。 Passing a GdkAtom as argument rather than a string seems to be the new requirement. 传递GdkAtom作为参数而不是字符串似乎是新要求。
New Gdk.Atom can be created with PyGtk with the gtk.gdk.atom_intern(str)
method. 可以使用
gtk.gdk.atom_intern(str)
方法使用PyGtk创建新的Gdk.Atom。 The corresponding C function in the documentation is gdk_atom_intern()
. 文档中相应的C函数是
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. 但是,PyGI中没有这样的方法:仅
dir(Gtk)
会返回Gdk.Atom或Gdk.atom_name,但不会返回Gdk.atom_intern。 The Gdk.Atom has no apparent method either. Gdk.Atom也没有明显的方法。 PS: it seems reading this code at line 139 that
Gdk.atom_intern()
would be available though. PS:似乎在第139行阅读了此代码 ,但
Gdk.atom_intern()
仍然可用。
Do you know how I could create (or find out how to create) a Gdk.Atom using PyGI with Gtk+3? 您知道如何使用PyGI和Gtk + 3来创建(或找到创建方法)Gdk.Atom吗?
Thanks. 谢谢。
It might be that Gobject-Introspection picks up Gdk from Gtk+-2.0 version, so you have to force the version: Gobject-Introspection可能从Gtk + -2.0版本中提取了Gdk,因此您必须强制使用该版本:
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. 为此,需要使用gir1.2-gtk-3.0软件包。 On Ubuntu it can be installed from repositories with
sudo apt-get install gir1.2-gtk-3.0
. 在Ubuntu上,可以使用
sudo apt-get install gir1.2-gtk-3.0
从存储库中sudo apt-get install gir1.2-gtk-3.0
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.