If you just want to insert text values then I'd use a GtkComboBoxText and call list.append_text()
for each item you want to add. Otherwise if you want to display something other than text or want to store some other information with the text values then you need to create a GtkTreeModel, tell the combobox to use it, and insert the values into that which is quite a bit more work.
python 2.7 show function results in gtk.combo
Pergunta
I'm looking for a solution to show the result of a fonction into a gtk.combo, in the main window. A simple example:
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()
I mean, how to put the result of def result_search in the gtk combo ?
Can anyone help ?
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow