Hello,

I'm having a hard time using a gtk.CellRendererCombo in my treeview
widget. The problem is that the combobox widget won't show. I've read
the pygtk reference a number times and the I get no errors executing
my code. I've created a small sample program which illustrates my
problem.

Any help is much appreciated, if someone can point me to a pygtk
program that uses gtk.CellRendererCombo that would be great.

John

#!/usr/bin/env python
import sys

try:
   import pygtk
   pygtk.require("2.6")
except:
   pass

try:
   import gtk
except:
   sys.exit(1)

class CellRendererExample:
   """ Main class of the application. """

   def __init__(self):
       # Create window and connect its destroy signal.
       window = gtk.Window()
       window.connect("destroy", gtk.main_quit)

       # Create and add a treeview widget to the window.
       self.treeview = gtk.TreeView()
       window.add(self.treeview)

       # Create a text column
       column0 = gtk.TreeViewColumn("Text",
                                   gtk.CellRendererText(),
                                   text=0)

       # Create a combobox column
       cellcombo = gtk.CellRendererCombo()

       model = gtk.ListStore(str)

       for k in range(1,10):
           model.append(["item_%d" % k])

       cellcombo.set_property("model", model)

       column1 = gtk.TreeViewColumn("Combobox", cellcombo)

       column1.add_attribute(cellcombo, "text-column", 1)

       self.treeview.append_column(column0)
       self.treeview.append_column(column1)

       # Create liststore.
       liststore = gtk.ListStore(str, int)

       # Append a couple of rows.
       liststore.append(["Some text", 0])
       liststore.append(["More text", 1])

       # Set model.
       self.treeview.set_model(liststore)

       window.show_all()

   def main(self):
       gtk.main()

if __name__ == "__main__":
   cre = CellRendererExample()
   cre.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/

Reply via email to