[pygtk] gtk combobox issues with glade+gtkbuilder ui tamplate
Bernard Gray
bernard.gray at gmail.com
Tue Aug 25 11:01:53 WST 2009
I got some assistance from crdlb on the irc channel and he cleared it
up for me - the issue was in how I was using the
combobox.add_attribute() function, and not populating the ListStore -
the final working app:
===============
#!/usr/bin/env python
import gobject, gtk
import os, sys
class Combos:
def delete_event(self, widget, event, data=None):
return False
def destroy(self, widget, data=None):
gtk.main_quit()
def __init__(self):
builder = gtk.Builder()
builder.add_from_file("cboxdebug.xml")
self.window = builder.get_object("window1")
builder.connect_signals(self)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
# populate combobox1
self.combobox1 = builder.get_object("combobox1")
liststore = gtk.ListStore(gobject.TYPE_STRING)
dynentries = ['foo1', 'foo2', 'foo3']
for entry in dynentries:
liststore.append([entry])
self.combobox1.set_model(liststore)
cell = gtk.CellRendererText()
self.combobox1.pack_start(cell, True)
self.combobox1.add_attribute(cell, 'text', 0)
def main(self):
gtk.main()
if __name__ == "__main__":
combos = Combos()
combos.window.show()
combos.main()
====================
On Tue, Aug 25, 2009 at 12:33 PM, Bernard Gray<bernard.gray at gmail.com> wrote:
> Hi All,
...
> Can somebody give me a clue about how to make this work?
>
> Thanks,
> Bernie
>
More information about the pygtk
mailing list