Python 创建简单PyGTK组合框会导致错误
我正在尝试创建一个简单的PyGTK组合框。但是,当我运行代码时,会出现运行时错误:Python 创建简单PyGTK组合框会导致错误,python,gtk,pygtk,Python,Gtk,Pygtk,我正在尝试创建一个简单的PyGTK组合框。但是,当我运行代码时,会出现运行时错误: 'comboBox = gtk.ComboBox.new_with_model(client_store)' AttributeError: type object 'gtk.ComboBox' has no attribute 'new_with_model' 如何创建PyGTK组合框?这是一个非常棘手的过程来创建这些小部件之一,我发现。注意,我在Python2.7上使用的是PyGTK版本2.24 任何关于如
'comboBox = gtk.ComboBox.new_with_model(client_store)'
AttributeError: type object 'gtk.ComboBox' has no attribute 'new_with_model'
如何创建PyGTK组合框?这是一个非常棘手的过程来创建这些小部件之一,我发现。注意,我在Python2.7上使用的是PyGTK版本2.24
任何关于如何创建简单组合框的建议都将不胜感激
import pygtk
pygtk.require('2.0')
import gtk
gtk.rc_parse('themes/Elegant Brit/gtk-2.0/gtkrc')
def create_combo_box(self):
client_store = gtk.ListStore(str)
for f in ("a","b","c"):
client_store.append([f])
comboBox = gtk.ComboBox.new_with_model(client_store) # Error occurs here
renderer_text = gtk.CellRendererText()
comboBox.pack_start(renderer_text, True)
comboBox.add_attribute(renderer_text, "text", 0)
return comboBox
正如错误告诉您的,gtk.ComboBox中没有新的_with_model方法。看 相反,使用comboBox=gtk.ComboBoxmodel=client\u store