2016-06-09 48 views
0

基本上我需要用這個來實現,就是繞過那個在窗口裏面沒有標識頂部欄的鼠標。正如你可以看到下面的代碼,如果你把鼠標放在頂欄上,窗口變成半透明,就好像鼠標不在那裏(mouse_enter()沒有被調用)。motion-notify-event not triggering

好吧,所以我認爲唯一的方法是獲取鼠標coordenates /位置並在mouse_move()函數中工作,現在的問題是motion-notify-event不會被解僱。

import gtk 

def mouse_move(window, event): 
    print(win.get_pointer()) 
    win.set_opacity(1) 

def mouse_enter(window, event): 
    win.set_opacity(1) 

def mouse_leave(window, event): 
    win.set_opacity(0.5) 

win = gtk.Window() 
win.set_opacity(0.5) 
win.set_size_request(600, 400) 

win.connect('enter-notify-event', mouse_enter) 
win.connect('leave-notify-event', mouse_leave) 
win.connect('motion-notify-event', mouse_move) 
win.connect('destroy', gtk.main_quit) 
win.show_all() 
gtk.main() 

回答

2

您可能需要調用win.add_events()使用Python相當於GDK_POINTER_MOTION_MASK

+0

Sintaticly我會怎麼做?我做了'win.add_events(POINTER_MOTION_MASK)',並拋出了'NameError:name'GDK_POINTER_MOTION_MASK'未定義' – Miguel

+1

我不知道;你需要查找一個PyGTK參考。抱歉。 – andlabs

+0

雖然@andlabs感謝 – Miguel