Try model = gtk.ListStore(object, *([str]*len(titles)))I have a few problems with the list/tree widgets. Before I forget, here is the version info
pythonPython 2.2.2 (#1, Jan 15 2003, 01:45:57)
[GCC 3.2.1 20021207 (Red Hat Linux 8.0 3.2.1-2)] on linux2
(2, 2, 0)import gtk
print gtk.gtk_version
My first problem is with creating a ListStore with a dynamic numbers of columns. The best thing I could come up with so far is this:
args = [gobject.TYPE_PYOBJECT] + ([gobject.TYPE_STRING] * len(titles)) model = apply( gtk.ListStore, args)
Is there a better way avoiding the use of "apply"?
This uses the "*args" syntax introduced in Python 2.0.
Make the first column type gtk.gdk.Color. Alternatively, you can make the first column a string column holding the colour name, and map "background" to the first column, rather than "background-gdk".
Second, I am trying to have different background colors for different row using the first column of of my model to hold the actual color:
for index in range(len(titles)):
renderer = gtk.CellRendererText() column = gtk.TreeViewColumn(titles[index], renderer, text=index+1) column.add_attribute(renderer,"background-gdk",0) view.append_column(column)
the values for the rows including the color rows are set here:
def redraw_events(self):
self._model.clear() for event in self._events: if event.get_type() == TYPE_REGULAR: fields = [self._color_normal] else: fields = [self._color_active] fields += self._viewer(event) iter = self._model.append() for i in range(len(fields)): self._model.set_value(iter, i, fields[i]) return
When running the program I get a lot of warnings like:
GLib-GObject-WARNING **: unable to set property `background-gdk' of type `GdkColor' from value of type `PyObject'
And, of course, my color settings are ignored. How do I work around this?
James.
-- Email: [EMAIL PROTECTED] WWW: http://www.daa.com.au/~james/
_______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
