Rich Burridge wrote:
> Given a gtk.TreeIter in a gtk.TreeModel, from:
>
http://www.pygtk.org/docs/pygtk/class-gtktreemodel.html#method-gtktreemodel--iter-next
> 
> I can see how to get the gtk.TreeIter pointing to the next row.
> But how to I get a gtk.TreeIter pointing to the previous row?
> 
> Just in case I'm taking the wrong approach here, what I want to do is move
> one (or more) selected rows, up one row.
> 
> I was expecting the code for the callback for the "Move up one" button
> to be something like:
> 
>     def textMoveUpOneButtonClicked(self, widget):
>         textSelection = self.getTextAttributesView.get_selection()
>         [model, paths] = textSelection.get_selected_rows()
>         for path in paths:
>             iter = model.get_iter(path)
>             prevIter = model.iter_prev(iter)
>             model.swap(iter, prevIter)
> 
> but there is no gtk.TreeMode.iter_prev() function.

Perhaps {TreeStore,ListStore}.insert_{before,after} would be useful.  Also,
you could manipulate path arithmetically (e.g., path[0] - 1) and then
convert path to iter.  Beware, though, if you are using a TreeStore rather
than a ListStore.  Also, I wonder whether you have considered using
drag-and-drop for rearranging rows rather than move buttons.
-- 
Jeffrey Barish

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

Reply via email to