[pygtk] gtk.treestore creation by script

Andi Albrecht albrecht.andi at googlemail.com
Tue Jan 20 13:55:38 WST 2009


On Sun, Jan 11, 2009 at 11:52 AM, ksadil <ksadil at proactiveindustrial.net> wrote:
> Hello,
>
>
>
> I am trying to make my treeview handling code a bit cleaner (and less
> verbose). I find myself rewriting very similar code each time that could be
>
> wrapped up in classes or methods, as I tend to make and use them in a
> similar way each time. I would like to create a "spec" file,  and have the
>
> script read the spec file and return the treeview and corresponding
> treestore. The only problem is that I don't know how to pass  a list of
> types
>
> to the gtk.treestore() method at runtime.
>
> I would like to be able to do something like:
>
>      column_types=[]
>
>      column_types.append(gtk.gdk.Pixbuf)
>
>      column_types.append(gobject.TYPE_STRING)
>
>      column_types.append(gobject.TYPE_INT)
>
>      my_treestore = gtk.treestore(column_types)

The asterisk is your friend... Try

  gtk.TreeStore(*column_types)

to benefit from Python's arg magic.


>
>
>
> Any ideas or suggestions would be greatly appreciated.
>
>
>
> Thanks,
>
> Kim
>
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>


More information about the pygtk mailing list