Re: Re: [pygtk] Liststore model

Jarek Zgoda jzgoda at o2.pl
Fri Jan 12 23:21:58 WST 2007


> 1. A select is send to a database:
> cur.execute("select position,article,name,amount,value from table_bill_pos")
> pos = cur.fetchall()
> 
> 2. depending on the result, I generate the model:
> listmodel = gtk.ListStore(int,str,str,str,str)
> 
> 3. create the TreeView:
> tv = gtk.TreeView(listmodel)
> 
> My problem is the second part, since I've got many queries against the database and changing the queries quite often. 
> So, I want to generate the _listmodel_ dynamically. Next time, maybe the query could be something like (int,str,str,str,str,str,int), because I added two  columns.

Cursor objects have description. It's a tuple, where second element is typecode. You can build your ListStore using that information.

Cheers
Jarek Zgoda


More information about the pygtk mailing list