How do I do something when user right click in a treeview's row?
Johan Dahlin
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)
来源:https://stackoverflow.com/questions/4570859/gtktreeviews-row-right-click