2014-02-14 32 views
1

我正在學習使用docs.python.org上列出的教程的Python GTK + 3。 更具體地說,我試圖執行基於ListBox的this demo programPython GTK + 3 AttributeError:gi.repository.Gtk對象沒有屬性'ListBox'

當我試圖執行它,外殼返回以下錯誤:

File "listboxex.py", line 55, in <module> 
    win=ListBoxWindow() 
File "listboxex.py", line 12, in __init__ 
    listbox=Gtk.ListBox() 
File "/usr/lib/python2.7/dist-packages/gi/module.py", line 313, in __getattr__ 
    return getattr(self._introspection_module, name) 
File "/usr/lib/python2.7/dist-packages/gi/module.py", line 134, in __getattr__ 
    self.__name__, name)) 
AttributeError: 'gi.repository.Gtk' object has no attribute 'ListBox' 

我要去哪裏錯了?另外我注意到shell正在使用Python 2.7執行我的代碼。我應該使用Python 3還是Python 3.3來執行我的代碼?我是一個Linux/Ubuntu新手,所以請告訴我如何!

回答

4

您的GTK + C版本庫沒有GtkListBox小部件。在2013年9月發佈的GTK + 3.10中引入了GtkListBox小部件.Ubuntu 13.10僅包含GTK + 3.8,而14.04將包含GTK + 3.10。

相關問題