当用户右键单击树视图的行时,如何执行某些操作?
答案 0 :(得分:4)
这很简单,只需听取“按钮按下事件”信号并使用treeview.get_path_at_pos()
来计算所选行:
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)