How do I move a selection up or down in a Treeview?
The idea is that I can have an up and down buttons to move the selection up a row or down a row.
My Treeview is using a ListStore. Not sure if that matters.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First off, I will be using C code as that’s what I’m familiar with. Should you have problems translating it to Python, then say so, and I will do my best to help.
The class you want to use for this is
GtkTreeSelection. Basically, what you do is:gtk_tree_view_get_selection)GtkTreeIter(gtk_tree_selection_get_selected).gtk_tree_model_iter_next/previous)gtk_tree_selection_select_iter)In my little test program, the callback for the “down” button looked like this:
(here is the full program for reference)
When connecting, I passed the TreeSelection object to the callback.
Edit: This is how Samuel Taylor translated the above to Python: