问题
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