[pygtk] Tutorial Question...

dave dave at immunitysec.com
Sun Aug 8 17:45:38 WST 2004


A PyGTK TreeModelRow object supports the Python sequence and iterator 
protocols. You can get an iterator to iterate over the column values in 
the row or use the for statement or list comprehension as well. A 
TreeModelRow uses the column number as the index to extract a value. For 

  liststore = gtk.ListStore(str, int)
  liststore.append(['Random string', 514])
  row = liststore[0]
  value1 = row[1]
  value0 = liststore['0'][0]

Are we supposed to be talking about TreeStore's here instead of liststores?

I'm currently doing a search on a TreeStore:
for row in treestore:
  if row[0]==searchedthing:
     return row

Hopefully that's going to work, although it'd be nice to have a clear 
example in the tutorial for non-gui-geniuses like myself.

-dave "always looking out for the complete newbie"

More information about the pygtk mailing list