Add context manager methods to wx.BusyCursor

Fixes #196
This commit is contained in:
Robin Dunn
2016-12-03 15:59:52 -08:00
parent 432e4056ce
commit ede75fdc8d
2 changed files with 10 additions and 1 deletions

View File

@@ -70,6 +70,12 @@ def run():
module.find('wxGetOsVersion.major').out = True
module.find('wxGetOsVersion.minor').out = True
c = module.find('wxBusyCursor')
# add context manager methods
c.addPyMethod('__enter__', '(self)', 'return self')
c.addPyMethod('__exit__', '(self, exc_type, exc_val, exc_tb)', 'pass')
#-----------------------------------------------------------------
tools.doCommonTweaks(module)
tools.runGenerators(module)

View File

@@ -29,7 +29,10 @@ class utils_Tests(wtc.WidgetTestCase):
self.assertTrue( wx.IsBusy())
wx.EndBusyCursor()
self.assertTrue(not wx.IsBusy())
def test_utilsBusyCursor3(self):
with wx.BusyCursor():
self.myYield()
def test_utilsSomeOtherStuff(self):
wx.GetBatteryState()