João Pinto
João Pinto

Reputation: 5619

How to identify if the current selected row is the last on a gtk.TreeView?

I am sorry if this looks a trivial question but I am still new to the complexity of the View/model/store scheme require to use the GTK Treeview. How to identify if the current selected item is the last item on a gtk.TreeView ? I don't have children so right now each node is just a row.

Upvotes: 1

Views: 522

Answers (1)

ptomato
ptomato

Reputation: 57930

To do that, you have to ask the view what row is selected, then ask the model whether that row is the last one. Like so:

selection = view.get_selection()
model, iter = selection.get_selected()
if iter is None:
    print "Nothing selected"
else:
    if model.iter_next(iter) is not None:
        print "Selected item was not last"
    else:
        print "Selected item was last"

Upvotes: 3

Related Questions