logo       

Re: Remove multiple rows from a sorted TreeView: msg#00124

gnome.gtk+.python

Subject: Re: Remove multiple rows from a sorted TreeView

On Wed, 2004-12-22 at 08:30 -0500, Chris Lambacher wrote:
> Have you looked at FAQ 13.15?
> http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq13.025.htp

I tried the second approach described in FAQ 13.25 but it won't work
when using a TreeModelSort (unless I'm missing something). I modified it
to the following code and at least it will remove the correct row, but
it can't handle multiple selections. The iterators doesn't seem to be
valid after removing the first one.

selection = treeview.get_selection()
sorted_model, selected = selection.get_selected_rows()
sorted_iters = [sorted_model.get_iter(path) for path in selected]
model = sorted_model.get_model()
for sorted_iter in sorted_iters:
child_iter = sorted_model.convert_iter_to_child_iter(None,
sorted_iter)
model.remove(child_iter)



Btw, I think FAQ 13.25 contains an error:

selection = treeview.get_selection()
model, selected = selection.get_selected_rows()
iters = [selection.get_iter(path) for path in selected]
^^^^^^^^^
for iter in iters:
model.remove(iter)

Shouldn't this be 'model' instead of 'selection'?

/ Mattias

> -Chris
>
>
> On Wed, 22 Dec 2004 13:59:32 +0100, Mattias Karlsson <enkidude@xxxxxxxxx>
> wrote:
> > Hi,
> >
> > I'm having trouble figuring out how to remove the selected rows
> > (multiple selection allowed) from a TreeView when the TreeModel is
> > wrapped in a TreeModelSort. Does anyone have any experience with this?
> > I'm quite new to Gtk, so maybe I've missed something obvious.
> >
> > cheers
> >
> > / Mattias
> >
> > _______________________________________________
> > pygtk mailing list pygtk@xxxxxxxxxx
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> >
>
>

_______________________________________________
pygtk mailing list pygtk@xxxxxxxxxx
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise