动作通知事件不触发 [英] motion-notify-event not triggering

查看:179
本文介绍了动作通知事件不触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我需要用这个来实现,就是绕过那个没有将顶部栏上的鼠标标识为窗口内部的错误。正如你在下面的代码中看到的那样,如果你将鼠标放在顶栏上,那么窗口会变成半透明的,就好像鼠标不在那里一样( mouse_enter() doesn'我们认为这样做的唯一方法就是从中获取鼠标合并/位置并开始工作。 mouse_move()函数,现在的问题是 motion-notify-event 不会被触发。

 导入gtk 

def mouse_move(窗口,事件):
print(win.get_pointer())
win .set_opacity(1)

find mouse_enter(窗口,事件):
win.set_opacity(1)

find 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('destr oy',gtk.main_quit)
win.show_all()
gtk.main()


win.add_events()和Python的等价物 GDK_POINTER_MOTION_MASK / code>。


Basically what i need to achieve with this is to bypass the bug which doesn't identify the mouse over the top bar as being inside the window. As you can see with the code below, if you put the mouse on top bar the window turns half-transparent as if the mouse aren't there (mouse_enter() doesn't get called).

Well, so i thought the only way to do this is to get mouse coordenates/position and work from there in the mouse_move() function, the problem now is that motion-notify-event doesn't get fired.

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()

解决方案

You likely need to call win.add_events() with the Python equivalent of GDK_POINTER_MOTION_MASK.

这篇关于动作通知事件不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆