[pygtk] Liststore model

Volker Helm Helm.volker at gmx.de
Fri Jan 12 23:16:36 WST 2007


Sorry for my bad english, I rarely use it.

For understanding. 

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.

I hope, this is understandable.

Thanks in advance



-------- Original-Nachricht --------
Datum: Fri, 12 Jan 2007 12:50:29 +0000
Von: "Alberto Ruiz" <aruiz at gnome.org>
An: "Volker Helm" <Helm.volker at gmx.de>
Betreff: Re: [pygtk] Liststore model

> 2007/1/12, Volker Helm <Helm.volker at gmx.de>:
> >
> > Hi,
> >
> > I'm trying to implement programm based on a database. Since there are a
> > lot of columns in a database I'd like to generate a gtk.ListStore model
> > dynamicly.
> >
> > normally, I'd do something like this:
> >
> > import pygtk
> > ...
> > win = gtk.Window()
> > listmodel = gtk.ListStore(str,str,str,int,str)
> > tv = gtk.TreeView(listmodel)
> > ...
> >
> > I'd prefer:
> >
> > import gtk
> > ...
> > win = gtk.Window()
> > listmodel = gtk.Liststore(str)
> > # now append some column to the model
> >
> > # go on
> > tv = gtk.Treeview(listmodel)
> >
> > Does anybody has an idea, how to solve this problem without using
> > completly the generic model?
> >
> > Thanks in advance,
> 
> 
> Sorry, but I don't get what the question is.
> 
> Volker
> >
> 
> -- 
> Un saludo,
> Alberto Ruiz

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer


More information about the pygtk mailing list