Python2.7在gtk.comb中显示函数结果

2024-10-02 10:24:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在寻找一个解决方案,将一个函数的结果显示在主窗口的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组合框中

有人能帮忙吗


Tags: selfboxnonetruegtksearchdatadownload
1条回答
网友
1楼 · 发布于 2024-10-02 10:24:31

如果您只想插入文本值,那么我将使用GtkComboBoxText并为每个要添加的项调用list.append_text()。否则,如果您想显示文本以外的内容,或者想用文本值存储其他信息,那么您需要创建一个GtkTreeModel,告诉组合框使用它,并将值插入到需要更多工作的内容中

相关问题 更多 >

    热门问题