Erik Grinaker wrote:

Is there a way to store a dict for a tree row?

Currently I have a column of type gtk.gobject.TYPE_INT, which stores an
integer pointer to a separate dict holding the dicts containing data for
the rows.

This works just fine, but I'm just wondering if it is possible to store
the dict inside the treestore instead of having to handle it myself...



You can store any python object in a model. For example:


   def dict_cell_data_func(column, cell, model, it, col_key):
      cell.set_property("text", model.get_value(it,col_key[0])[col_key[1]])

   myModel = gtk.ListStore(object)
   tv = gtk.TreeView(myModel)
   textRend = gtk.CellRendererText()
   col = gtk.TreeViewColumn("Foo", textRend)
   col.set_cell_data_func(textRend, dict_cell_data_func, (0,'foo'))
   tv.append_column(col)

   someobj = {'foo': 'foo text'}
   myModel.append((someobj,))



_______________________________________________
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