1

I have a gtk treeview that I'm using like a list view and I want to give it a callback that activates when the user clicks (single click, not double click) a single entry in it. I know the activated callback for the treeview widget activates for double clicks, and if I have only been able to set up the gtk.gdk.event for single click on the entire treeview widget witch is not the behavior that I'm looking for. Further more the cellrenderer objects inside it don't inherit the widget class which makes it so I can't give the callback to that one in particular. Can someone please tell me how to get the callback for a single click on an item in a gtk treeview working?

P.S. Any language is fine, but I would prefer python since that's what my app is written in.

1 Answer 1

1

If you are using a gtk.SELECTION_SINGLE or gtk.SELECTION_MULTIPLE with your treeview, a single left-click would select the row. You can attach to this event by using the set_select_function or attaching to the changed signal.

Sign up to request clarification or add additional context in comments.

2 Comments

Ok, so I used the set_select_function and I ends up getting called twice if I return true, and ends up in an infinite loop if I tell it to select the path explicitly. Is there anything I can do about it?
@user381261, if you have SELECTION_SINGLE, it is called twice, once for the row being selected and once for the row that is being toggle unselected. If you use the full=True, you can determine which row gets the click by looking at is_selected == False.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.