在 wxPython 中 event.Skip() 和 event.Veto() 有什么区别? [英] In wxPython what is the difference between event.Skip() and event.Veto()?

查看:37
本文介绍了在 wxPython 中 event.Skip() 和 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

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

在本指南中:http://zetcode.com/wxpython/events/它说:

有时我们需要停止处理事件.为此,我们调用方法否决().

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

但这听起来与 Skip() 所做的完全一样.

but that sound exactly like what Skip() does.

那么差异是什么?

推荐答案

Veto() 用于阻止处理事件,但 Skip() 允许传播事件和处理进一步"事件.
有两种类型的事件.基本事件和命令事件.它们的传播方式不同.事件传播是事件从子小部件到父小部件和大父小部件等的进程.基本事件不会传播.命令事件确实会传播.
此外,您可以将多个事件绑定到一个控件,默认情况下,事件处理程序中捕获的事件停止传播.要继续传播或处理其他绑定事件,请调用 Skip() 方法.我希望这个解释是清楚的.

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.

这篇关于在 wxPython 中 event.Skip() 和 event.Veto() 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆