【发布时间】:2012-12-22 20:55:56
【问题描述】:
所以我一直在尝试将 C GNOME 小程序移植到 MATE,在遇到许多不同的问题后,我决定用 python 从头开始重写它。最终,我找到了一些过时的文档,这里是:http://wiki.mate-desktop.org/docs:devel:mate-panel
显然,在 python 中编写小程序的新方法是使用 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.
编辑:如果我运行
import gi
gi.require_version("Gtk", "2.0")
在 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
这几乎回答了问题 3,但随后又提出了问题 1。此外,即使我安装了 libmatepanelapplet-dev,运行 from gi.repository import MatePanelApplet 也会出现 ImportError Could not find any typelib for MatePanelApplet。
再次编辑:我在这里找到了 ImportError 的解决方案:Can't import Webkit from gi.repository。 (只需安装 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)
【问题讨论】:
标签: python gnome pygobject mate-desktop