mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 11:30:06 +01:00
Use wx.EventBlocker as a context manager in the sample code snippet in the docs
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user