In wxPython what is the difference between event.Skip() and event.Veto()?

江枫思渺然 提交于 2020-02-04 04:42:08

问题


I have a NOTEBOOK with the following event:

self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging)

What is the diffrance between the following codes?

def OnPageChanging(self, event):
    try:
        if .....
            do some actions...
            event.Veto()
            return
    except:
        pass

and

def OnPageChanging(self, event):
    try:
        if .....
            do some actions...
            event.Skip()
            return
    except:
        pass

In this guide: http://zetcode.com/wxpython/events/ it says:

Sometimes we need to stop processing an event. To do this, we call the method Veto().

but that sound exactly like what Skip() does.

So what is the diffrance?


回答1:


Veto() is used to prevent processing of an event but Skip() allows propagation of events and processing of "further" events.
There are two types of events. Basic events and command events. They differ in propagation. Event propagation is the progressing of events from child widgets to parent widgets and grand parent widgets etc. Basic events do not propagate. Command events do propagate.
Also, you may bind more than one event to a control, by default, the event that is caught in a event handler stops propagating. To continue propagation or process other bound events, call the Skip() method. I hope that this explanation is clear.



来源:https://stackoverflow.com/questions/34035568/in-wxpython-what-is-the-difference-between-event-skip-and-event-veto

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!