2012-12-22 50 views
4

所以我一直在嘗試將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) 

回答

3

MATE是GNOME 2的叉,因此,你應該使用PyGTK的(因爲你得到的消息)。

對於每一個問題:

  1. PyGObject更好,因爲你只需要一個單一的綁定到庫(在提供內省之一),你會得到每一個支持圖書館的公共API自動訪問GOBject的反思。對於開發人員來說是好事,因爲他們可以訪問與C相同的API,而無需等待每個新版本的綁定。

  2. 是的。但用戶可能會有。 GNOME 3的可能性是100%,而GNOME 2(MATE)則更少,因爲它不是必需的。

  3. 這看起來不像一個問題。正如我以前所說,MATE是用於GNOME 2的,因此你必須使用庫和文檔,可用於GNOME 2

您可以檢查是用Python寫的GNOME 2小程序(後GNOME放棄了Bonobo)。例如,hasmter。您可能需要更改一些名稱,可能在MATE中將庫名稱從GNOME重命名爲MATE。