右键单击Gtk TreeView行

时间:2010-12-31 15:25:40

标签: click pygtk right-click treeviewitem gtktreeview

当用户右键单击树视图的行时,如何执行某些操作?

1 个答案:

答案 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)