如何防止" leave-notify-event"将标题栏视为窗外?

时间:2016-06-09 05:09:47

标签: python gtk pygtk

我在Python 2.7中使用pyGTK,当鼠标在窗口外时我会设置win.set_decorated(False),当鼠标在窗口内时我会设置win.set_decorated(True)

以下代码有效,但有问题。当我将鼠标放在标题栏上时,标题栏会出现崩溃循环。因为leave-notify-event将标题栏视为窗外。我该如何解决?

import gtk 

def mouse_enter(win, event): 
    win.set_decorated(True) 

def mouse_leave(win, event): 
    win.set_decorated(False) 

win = gtk.Window() 
win.connect('enter-notify-event', mouse_enter) 
win.connect('leave-notify-event', mouse_leave) 
win.connect('delete-event', gtk.main_quit) 
win.show_all() 
gtk.main()

0 个答案:

没有答案