[pygtk] Change gtkListStore model dynamically

SK Keeper skkeeper at gmail.com
Tue Jul 26 02:32:59 WST 2011


Hi everyone,

So I finally got around to understand how PyGTK really works and I'm working
on a simple SQLite manager app.

To show the result of a query I'm using a gtk.ScrolledWindow with a
gtk.TreeView. I've managed to add and even change the values in the
ListStore object as I need, what I can't do is change the model of the
ListStore object.

For example in one query I may have a result of two columns:

    self.query_results = gtk.ListStore(str,str)

    self.query_results.append(["1"],["John Doe"])

And in another one I may get more columns:

    self.query_results = gtk.ListStore(str,str,str,str)

    self.query_results.append(["20"],["Jane"],["jane at example.com"],["password"])

I know I can use stuff like

     self.query_results = gtk.ListStore(*[str]*len(columns))

But aparently gtk.ListStore cannot have it's model changed after being
created, so how would I update this query table? Do I need to destroy the
Treeview and draw it again everytime I run a different query?

Thanks :)
-------------------------------------------
SK Keeper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.daa.com.au/pipermail/pygtk/attachments/20110725/b3a3da99/attachment-0001.html>


More information about the pygtk mailing list