所以我一直在嘗試將C GNOME小程序移植到MATE,並且在遇到許多不同的問題後,我決定在python中從頭開始重寫它。最終,我發現了一些不太可怕的文檔,這裏是:http://wiki.mate-desktop.org/docs:devel:mate-panel用PyGObject自省編寫MATE/GNOME小程序(Python)
顯然,在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.
編輯:如果我在Python會話中運行
import gi
gi.require_version("Gtk", "2.0")
,我得到警告:
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)