Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyGTK休假通知事件';如果输入children,则不会触发_Python_Pygtk - Fatal编程技术网

Python PyGTK休假通知事件';如果输入children,则不会触发

Python PyGTK休假通知事件';如果输入children,则不会触发,python,pygtk,Python,Pygtk,请参见以下代码示例: import gtk class MenuBox(gtk.EventBox): def __init__(self): super(MenuBox, self).__init__() self.set_visible_window(False) self.connect('enter-notify-event', self._on_mouse_enter) self.connect('leave-n

请参见以下代码示例:

import gtk


class MenuBox(gtk.EventBox):
    def __init__(self):
        super(MenuBox, self).__init__()
        self.set_visible_window(False)
        self.connect('enter-notify-event', self._on_mouse_enter)
        self.connect('leave-notify-event', self._on_mouse_leave)

        btn = gtk.Button('x')
        btn.set_border_width(12)
        self.add(btn)

    def _on_mouse_enter(self, wid, event):
        print '_on_mouse_enter'

    def _on_mouse_leave(self, *args):
        print '_on_mouse_leave'


def main():
    win = gtk.Window()
    win.connect('destroy', gtk.main_quit)
    win.add(MenuBox())
    win.show_all()
    gtk.main()

if __name__ == '__main__':
    main()
我希望,如果我从父级转到子级并返回,则不会触发“进入”和“离开”事件。我知道在这种特殊情况下,我可以使用
event.detail
过滤这些事件。但如果没有边界,这是行不通的。如果删除边框,则事件根本不会触发

在我的真实代码中,我有一个更复杂的小部件(基于gtk.Fixed),它在开头有边框,但在结尾没有边框。因此,仅仅将事件转移到孩子身上也不会奏效

#        self.set_visible_window(False)
        self.connect('enter-notify-event', self._on_mouse_enter)
        self.connect('leave-notify-event', self._on_mouse_leave)

        btn = gtk.Button('x')
#        btn.set_border_width(12)
这就是你需要的吗


这就是您需要的吗?

从功能的角度来看,是的。但我也需要EventBox的窗口不可见。因为我有一个背景图像,否则会被EventBox窗口覆盖。从功能的角度来看,是的。但我也需要EventBox的窗口不可见。因为我有一个背景图像,否则会被EventBox窗口覆盖。