Search code examples
pythoneventswxpythonwxwidgets

When to use event.Skip() in wxPython event handlers?


In wxPython you often see that in event handlers after doing stuff, event.Skip() is called, which - in my understanding - prevents the event handling from stopping at this point but let it rather propagate to the next event handler, if there is any.

def onButton(event):
    # Doing stuff after button is clicked
    event.Skip()

What I don't understand is: Is it (always) necessary to call event.Skip()? Or only in specific cases? Or is it more or less good practice to do so?


Solution

  • Arguably, this is all about event propagation (but only for wx.CommandEvents, as only they propagate), so unless you have a specific need to call event.Skip(), you shouldn't call it, as a matter of course. To do so, simply means that you are executing more code than you need to.
    http://wiki.wxpython.org/EventPropagation