From 2c5c104a79465f27c2ef83ffff2264e3fd7c86b7 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 25 Sep 2018 13:55:05 -0700 Subject: [PATCH] Use wx.EventBlocker as a context manager in the sample code snippet in the docs --- .../snippets/python/converted/wx.EventBlocker.1.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/sphinx/rest_substitutions/snippets/python/converted/wx.EventBlocker.1.py b/docs/sphinx/rest_substitutions/snippets/python/converted/wx.EventBlocker.1.py index adcb1d6a..cdf649cf 100644 --- a/docs/sphinx/rest_substitutions/snippets/python/converted/wx.EventBlocker.1.py +++ b/docs/sphinx/rest_substitutions/snippets/python/converted/wx.EventBlocker.1.py @@ -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)