[pygtk] What have I got wrong? (using glade, gtk.TreeView, and gtk.ListStore)

Michael R Head burner at suppressingfire.org
Fri Aug 19 02:25:35 WST 2005


I'm just starting out with pygtk, and I'm having some trouble putting
rows into a table. Despite the fact that I am adding rows (and I can
tell that rows are being added by the selection bar in the screenshot),
The text in them doesn't appear. I've changed the default cell renderer
to  gtk.CellRendererText and have been able to set the background color,
but the text of the elements in the row simply doesn't show up. 

I must be doing something very simple, but I can't figure out what's so
different from the various examples of pygtk tables that I've looked at
and run.

I am using Ubuntu Hoary's packages of python (2.4.1), gtk (2.6.4) and
pygtk (2.6.1).

Here's my python source:
===============================================================
#!/usr/bin/env python

import gtk
import gtk.glade
import gobject

APPNAME="Labelator"
APPVERSION="0.1"

class WidgetsWrapper:
        def __init__(self):
                """
                """
                self.widgets = gtk.glade.XML('labelator.glade',
'Labelator')
                dic = {'gtk_main_quit': gtk.main_quit,
                           'on_quit1_activate': self.on_quit1_activate}
                self.widgets.signal_autoconnect(dic)

                table = self.widgets.get_widget('MainTable')

                liststore =
gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_STRING)

                for column in ("Column 1", "Column 2"):
                        table_column = gtk.TreeViewColumn(column)
                        table.append_column(table_column)

                for row in (("Column 1/Row 1", "Column 2/Row 1"),
("Column 1/Row 2", "Column 2/Row 2")):
                        liststore.append(row)

                table.set_model(liststore)

        def on_quit1_activate(self, event):
                gtk.main_quit()

if __name__ == "__main__":
        widgets = WidgetsWrapper()
        gtk.main()
===============================================================


The glade file and (small) screenshot of my run are attached.

thanks,
mike

-- 
Michael R Head <burner at suppressingfire.org>
burner | suppressingfire | firestorm | phoenix | firefighter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot-Labelator.png
Type: image/png
Size: 6627 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20050818/77bbba6d/Screenshot-Labelator.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: labelator.glade
Type: application/x-glade
Size: 2025 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20050818/77bbba6d/labelator.bin


More information about the pygtk mailing list