Use wx.EventBlocker as a context manager in the sample code snippet in the docs

This commit is contained in:
Robin Dunn
2018-09-25 13:55:05 -07:00
parent ec881453a9
commit 2c5c104a79

View File

@@ -2,12 +2,13 @@
def DoSomething(self):
# block all events directed to this window while
# we do the 1000 FunctionWhichSendsEvents() calls
blocker = wx.EventBlocker(self)
with wx.EventBlocker(self) as blocker:
for i in xrange(1000):
FunctionWhichSendsEvents(i)
for i in xrange(1000):
FunctionWhichSendsEvents(i)
# wx.EventBlocker destructor called, old event handler is restored
# wx.EventBlocker destructor called on exit from the context
# manager, old event handlers are restored.
# the event generated by this call will be processed:
FunctionWhichSendsEvents(0)