如何设置 ComboBoxText 的活动文本(带条目)?
文档中没有这种方法。
那这个呢:
#-*- coding: UTF-8 -*-
from gi.repository import Gtk
class App(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title='ComboBoxEntry Test')
model = Gtk.ListStore(str, str)
for i in [['One', '1'], ['Two', '2'], ['Three', '3'], ['Four', '4']]:
model.append(i)
combo = Gtk.ComboBoxText.new_with_entry()
combo.set_model(model)
#combo.set_active(0)
combo.get_child().set_text('Five')
self.add(combo)
win = App()
win.connect('delete-event', Gtk.main_quit)
win.show_all()
Gtk.main()