Reputation: 51
How do I do something when user right click in a treeview's row?
Upvotes: 5
Views: 3499
Reputation: 26566
It's really easy, just listen to the "button-press-event" signal and use treeview.get_path_at_pos()
to figure the selected row:
def button_press_event(treeview, event):
if event.button == 3: # right click
model, path = treeview.get_path_at_pos(int(event.x), int(event.y))
# do something with the selected path
treeview.connect('button-press-event' , button_press_event)
Upvotes: 3