使用pygtk 2.24和glade 3时,我在使用组合框时遇到了问题。当我单击其中的一个项目时,我得到以下错误信息
interface.py:94: Warning: unable to set property `text' of type `gchararray' from
value of type `glong'
gtk.main()我的combobox代码在这里
#get the combo box out of the builder and add items to it
self.cbmoRepresentation = builder.get_object("cmbo_representation")
self.iface_list_store = gtk.ListStore(gobject.TYPE_STRING)
self.iface_list_store.append(["Row-Column"])
self.iface_list_store.append(["Row-Number"])
self.iface_list_store.append(["Number-Column"])
self.cbmoRepresentation.set_model(self.iface_list_store)
cell = gtk.CellRendererText()
self.cbmoRepresentation.pack_start(cell, True)
self.cbmoRepresentation.add_attribute(cell, "text", 0)
self.cbmoRepresentation.set_active(-1)任何帮助都会非常感谢:)。
发布于 2011-09-10 20:37:04
我有这样的工作(但我不使用glade):
liststore = gtk.ListStore(gobject.TYPE_STRING)
combobox = gtk.ComboBox(liststore)
cell = gtk.CellRendererText()
combobox.pack_start(cell, True)
combobox.add_attribute(cell, 'text', 0)所以我怀疑你的self.cbmoRepresentation类型不正确。请尝试:
self.cbmoRepresentation = builder.get_object("cmbo_representation")
print type(self.cbmoRepresentation)检查cbmoRepresentation的类型。
https://stackoverflow.com/questions/7371645
复制相似问题