2011-09-10 49 views
0

使用pygtk 2.24和glade 3我遇到組合框有問題。當我在它單擊一個項目,我得到了以下錯誤消息在組合框中選擇一個項目pygtk glade3

interface.py:94: Warning: unable to set property `text' of type `gchararray' from 
value of type `glong' 
gtk.main() 

我的組合框代碼是在這裏

#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) 

任何幫助將非常感激:)。

回答

0

我有這樣的作品(但我不使用林間空地):

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的類型。

+0

是輸出。 – Harpy

相關問題