我正在寻找一个解决方案,将一个函数的结果显示在主窗口的gtk.combo中。 一个简单的例子:
def download(self, a, data=None):
print "result1 dowloaded"
def result_search(self, a, data=None):
# fonction to search differents results
result = [result1, result2, result3]
self.listchain = result #pseudocode
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.box = gtk.VBox(False, 0)
self.list = gtk.Combo()
self.listchain = [" "," "," "] # empty, but full after the search
self.list.set_popdown_strings(self.listchain)
self.list.entry.connect("activate", self.download, self.listchain)
self.box.pack_start(self.liste, True, True, 0)
self.liste.show()
我的意思是,如何将def result\u search的结果放在gtk组合框中
有人能帮忙吗
如果您只想插入文本值,那么我将使用GtkComboBoxText并为每个要添加的项调用
list.append_text()
。否则,如果您想显示文本以外的内容,或者想用文本值存储其他信息,那么您需要创建一个GtkTreeModel,告诉组合框使用它,并将值插入到需要更多工作的内容中相关问题 更多 >
编程相关推荐