动作通知事件不触发

时间:2016-06-09 09:10:02

标签: python gtk

基本上我需要实现的是绕过顶部栏上没有识别鼠标的错误,因为它位于窗口内部。正如您在下面的代码中看到的那样,如果您将鼠标放在顶部栏上,则窗口会变为半透明,就像鼠标不在那里一样(mouse_enter()不会被调用)。

好吧,所以我认为唯一的方法就是让鼠标协同定位/位置并在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()

1 个答案:

答案 0 :(得分:2)

您可能需要使用等效于win.add_events()的Python来调用GDK_POINTER_MOTION_MASK