gen*_*ass 5 python gnome pygobject mate-desktop
因此,我一直试图将C GNOME小程序移植到MATE,在遇到许多不同的问题后,我决定在python中从头开始重写它。最终,我找到了一些并非非常过时的文档,该文档位于:http ://wiki.mate-desktop.org/docs:devel:mate-panel
显然,用python编写applet的新方法是使用PyGObject自省,而不是“旧的” PyGtk。
所以我有几个问题:
1. Why is it better to use PyGObject instead of PyGtk etc
2. Is the end user who downloads a python applet expected to have pygobject installed? It looks like it.
3. The MATE documentation says 'ensure we are using Gtk 2, not Gtk3', but http://python-gtk-3-tutorial.readthedocs.org/en/latest/install.html says that its exclusively supports Gtk+ 3 and higher.
Run Code Online (Sandbox Code Playgroud)
编辑:如果我运行
import gi
gi.require_version("Gtk", "2.0")
Run Code Online (Sandbox Code Playgroud)
在python会话中,我得到警告:
RuntimeWarning: You have imported the Gtk 2.0 module. Because Gtk 2.0 was not designed for use with introspection some of the interfaces and API will fail. As such this is not supported by the pygobject development team and we encourage you to port your app to Gtk 3 or greater. PyGTK is the recomended python module to use with Gtk 2.0
Run Code Online (Sandbox Code Playgroud)
哪个几乎回答了问题3,但是又提出了问题1。另外,即使安装了libmatepanelapplet-dev ,运行也会from gi.repository import MatePanelApplet给出ImportError Could not find any typelib for MatePanelApplet。
再次编辑:我在这里找到了ImportError的解决方案:无法从gi.repository导入Webkit。(只需安装gir1.2-mate-panel而不是webkit)
还有更多错误:
./xmonad-log-applet.py:66: Warning: g_closure_set_marshal: assertion `closure != NULL' failed
applet = MatePanelApplet.Applet()
(xmonad-log-applet.py:10928): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion `G_IS_DBUS_CONNECTION (connection)' failed
Segmentation fault (core dumped)
Run Code Online (Sandbox Code Playgroud)
MATE 是 GNOME 2 的一个分支,因此您应该使用 PyGTK(如您收到的消息)。
关于每个问题:
PyGObject 更好,因为您只需要与库(提供自省的库)进行一次绑定,并且您可以自动访问支持 GOBject 自省的每个库的公共 API。对于开发人员来说这是件好事,因为他们可以访问与 C 相同的 API,而无需等待每个新版本的绑定。
是的。但用户可能会有。GNOME 3 的可能性是 100%,GNOME 2 (MATE) 的可能性较小,因为它不是必需的。
这看起来不像是一个问题。正如我之前所说,MATE 是 GNOME 2 的一个版本,因此您必须使用 GNOME 2 可用的库和文档。
您可以检查用 Python 为 GNOME 2 编写的小程序(在 GNOME 删除 Bonobo 之后)。例如,hasmter。您可能需要更改一些名称,例如在 MATE 中将库名称从 GNOME 重命名为 MATE。