[pygtk] back to my tree view

Thomas Mills Hinkle tmhinkle at gmail.com
Wed Oct 25 10:08:52 WST 2006


On 10/24/06, shawn bright <nephish at gmail.com> wrote:
>
> ok, i have my tree view and populated with a list like the tutorial said,
> however, i need a way to refresh the list.
> here is what i have so far
>
> self.group_treeiter =3D self.group_model.get_iter_first()
> self.group_model.clear ()
> for name in name_list:
>             self.treeiter =3D self.group_model.append(None,name)
> self.group_tree_view.set_model(self.group_model)
> self.group_column =3D gtk.TreeViewColumn('Groups')
> self.group_tree_view.append_column (self.group_column)
> self.view =3D gtk.CellRendererText()
> self.group_column.pack_start(self.view, True)
> self.group_column.add_attribute(self.view, 'text', 0)
>
> it works so far, but when i run it again, instead of clearing out the list
> view, it starts a new column.
> this just cannot be. Anyone see off hand what i am doing wrong here?


All of the code relating to the treeview (as opposed to the tree model)
should only be called once.

The idea here is that display (the treeview) and the underlying data model
(treemodel) are separate. You set up a treeview with columns, etc., only
once -- changes in the treemodel will then automatically be reflected in the
display.

So the only call above that you need to repeat are:

self.group_model.clear ()
self.group_treeiter =3D self.group_model.get_iter_first()
for name in name_list:
            self.treeiter =3D self.group_model.append(None,name)

Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20061024/b41650b6/at=
tachment-0001.htm


More information about the pygtk mailing list