2010-11-07 58 views

回答

2

覆蓋這種行爲可能會混淆用戶。但是,如果你真的想,有兩種可能性,我可以看到:

要麼使IconView相信Ctrl鍵總是按:

def force_ctrl(iv, ev): ev.state |= gtk.gdk.CONTROL_MASK 
iconview.connect('key-press-event', force_ctrl) 
iconview.connect('button-press-event', force_ctrl) 

或者你可以嘗試自己實施的選擇行爲,事如:

def clicked(iv, ev): 
    p = iv.get_path_at_pos(int(ev.x), int(ev.y)) 
    if not p is None: 
     if iv.path_is_selected(p): 
      iv.unselect_path(p) 
     else: 
      iv.select_path(p) 
    return True # make the IconView ignore this click 
iconview.connect('button-press-event', clicked)