我遇到了gtk ComboBoxEntry的问题。当我尝试更改组合框中的文本时,我的程序崩溃了。我使用这段代码:
gui.combo_txt_script.get_child().set_text(fshort)
它因错误而崩溃:
AttributeError: 'NoneType' object has no attribute 'set_text'
以下照片的结果:
print "combo:",gui.combo_txt_script
print "entry:",gui.combo_txt_script.get_child()
是
combo: <gtk.ComboBoxEntry object at ... >
entry: None
答案 0 :(得分:0)
已更新
Gtk.ComboBox
个对象的获取和设置当前值与这些对象的 model 属性相关,您可以在代码下设置和/或获取类似的项目:
model = combo.get_model()
value = model[combo.get_activate()][0]
# first index refers to row of list
# second index refers to cell in the row. by default an combo/combo-entry have one cell
combo.set_activate(list(model).index(value))
答案 1 :(得分:0)
我发现了问题。我使用的程序有不同的用户级别。每个选项卡以及每个窗口小部件对于每个用户级别都不可见。不知何故,用户级别可能会自行更改,这使得组合不存在。