当前位置: 动力学知识库 > 问答 > 编程问答 >

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

问题描述:

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?

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: