On Fri, 07 Nov 2003 10:56:56 +0100
Harobed <[EMAIL PROTECTED]> wrote:
> Le jeu 06/11/2003 � 19:18, Harobed a �crit :
> > Hello,
> >
> > I would like append value to combo.list
> >
> > This code don't work :
> >
> > combo=gtk.Combo()
> > combo.list.append("foo") <-- error here
> >
> > Warning: I don't want use combo.set_popdown_strings() !
> >
> > I would control the list.
> >
> > Thanks
> Nobody can help me ?
a working example is attached.
walter
#!/usr/bin/env python
try:
import pygtk; pygtk.require('2.0')
except:
pass
import gtk
class ComboExample:
def callback(self, combo_entry):
text = combo_entry.get_text()
# the "changed" signal seemingly occurs twice if a list item will be selected:
# first when the text in the entry is deleted; then when a new string
# is written into
if text != "":
print "Combo contents: %s" % text
def __init__(self):
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("delete_event", gtk.mainquit)
window.set_border_width(10)
combo = gtk.Combo()
window.add(combo)
combo.show()
listitem = gtk.ListItem("String 1")
combo.list.append_items([listitem])
# this is necessary, even a window.show_all() at the end is of no use
listitem.show()
listitem_a = gtk.ListItem("String 2")
listitem_b = gtk.ListItem("String 3")
combo.list.append_items([listitem_a, listitem_b])
listitem_a.show()
listitem_b.show()
# uncomment the next line to remove the last item
#combo.list.remove_items([listitem_b])
combo.entry.connect("changed", self.callback)
combo.entry.set_editable(gtk.FALSE)
window.show()
def main():
gtk.main()
return 0
if __name__ == "__main__":
ComboExample()
main()
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/