[pygtk] Trouble getting a ListStore with dynamic column number.
Stephen George
steve_geo at optusnet.com.au
Fri Feb 1 08:44:06 WST 2008
Neil Dugan wrote:
> Hi,
>
> I am trying to create a dialog with a gtk.TreeView() with a =
> gtk.ListStore() model. I don't know until run time how many columns =
> will be needed. I have managed to create the TreeView but I haven't =
> worked out how to populate it.
>
> Any help appreciated.
>
> Regards Neil.
Hi Neil,
I think your problem steams from the line
dialog._model =3D gtk.ListStore(object)
Which I think should be more like
dialog._model =3D gtk.ListStore(str,str,str)
However this does not give you the dynamic nature you desire.
I don't know the limits of column expansion/contraction you require for =
your problem, .. but I see in your code you want to limit it to 20
(are they always strings?, or all columns the same type?)
I would create a listStore with 20 str as arguments.
I would then create the treeview with as many columns needed for the =
problem at hand
Attached you will see a modified prog that works for me, I limited the =
columns to 7, each time you press the dialog button, a list is =
dynamically generated with a random number of columns.
Assumptions:
the list is always strings.
length of list correlates to number of colomns to view.
Don't know if this has been helpful?
Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list_test.py
Type: text/x-python
Size: 4943 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20080201/99e41b1b/l=
ist_test.py
More information about the pygtk
mailing list