|
Re: Remove multiple rows from a sorted TreeView: msg#00125gnome.gtk+.python
Sorry, that should be model. the faq has been updated. I have never tried to delete multiple entries on a sorted model. I would try converting all the iters before removing any: selection = treeview.get_selection() sorted_model, selected = selection.get_selected_rows() model = sorted_model.get_model() iters = [sorted_model.convert_iter_to_child_iter(None, sorted_model.get_iter(path)) for path in selected] for iter in iters: model.remove(iter) -Chris On Wed, 22 Dec 2004 16:56:34 +0100, Mattias Karlsson <enkidude@xxxxxxxxx> wrote: > 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/ > > > > > > > > > -- Christopher Lambacher lambacck@xxxxxxxxxxxx _______________________________________________ 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> |
|---|---|---|
| Previous by Date: | Re: Remove multiple rows from a sorted TreeView: 00125, Mattias Karlsson |
|---|---|
| Next by Date: | Re: Remove multiple rows from a sorted TreeView: 00125, Mattias Karlsson |
| Previous by Thread: | Re: Remove multiple rows from a sorted TreeViewi: 00125, Mattias Karlsson |
| Next by Thread: | Re: Remove multiple rows from a sorted TreeView: 00125, Mattias Karlsson |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |