【发布时间】:2014-06-14 22:49:09
【问题描述】:
ComboBoxEntry 和填充它的函数有问题。
这是 GUI 上的 __init__ 代码。
self.combobox_category = self.builder.get_object("combobox_category")
self.combobox_category.set_entry_text_column(1)
INIT_COMBOBOX_category(self)
这是填充ComboBoxEntry 的函数。
def INIT_COMBOBOX_category(self):
self.list_category = Gtk.ListStore(int,str)
self.list_category.clear()
self.list_category.append([0,"< List all the categories >"])
self.list_category.append([1,"No specified"])
#...No relevant code...
self.combobox_category.set_model(self.list_category)
self.cell = Gtk.CellRendererText()
self.combobox_category.pack_start(self.cell, True)
self.combobox_category.add_attribute(self.cell, 'text', 1)
self.combobox_category.set_active(1)
问题是当我启动 GUI 时,combobox_category 有“重复值”
(仅在选择值时,不在ComboBoxEntry 中):
< List all the categories > < List all the categories >
No specified No specified
然后,当我需要再次使用函数INIT_COMBOBOX_category(self) 时,值会增加三倍,等等。
我认为
self.list_category.clear()
不工作。
奇怪的是,在 Glade 中,我选择了 ComboBoxEntry 为“可编辑”,我不能在上面写字。我也试过“覆盖模式”,还是不行!
【问题讨论】:
标签: python gtk glade pygobject