因此,我一直试图将C GNOME小程序移植到MATE,在遇到许多不同的问题后,我决定在python中从头开始重写它。最终,我找到了一些并非非常过时的文档,在这里:http://wiki.mate-desktop.org/docs:devel:mate-panel
显然,用python编写applet的新方法是使用PyGObject自省(introspection),而不是“旧的” 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 session 中,我得到警告:
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)
最佳答案
MATE是GNOME 2的分支,因此您应该使用PyGTK(作为您收到的消息)。
关于每个问题:
您可以检查在Python中为GNOME 2编写的applet(在GNOME删除Bonobo之后)。例如,hasmter。您可能需要更改一些名称,可能在MATE中将库名称从GNOME重命名为MATE。