From 15eca0a39928a65c1b83d2ed2c768284daa8cf50 Mon Sep 17 00:00:00 2001 From: James Wettenhall Date: Thu, 23 Mar 2017 21:59:09 +1100 Subject: [PATCH] Monkey-patching RibbonGallery's Layout method avoids this exception: wx\lib\agw\ribbon\gallery.py, line 745, in Layout for item in self._items[indx:]: UnboundLocalError: local variable 'indx' referenced before assignment Monkey-patching RibbonGallery's OnPaint method avoids this exception: wx\lib\agw\ribbon\gallery.py, line 587, in OnPaint dc.SetClippingRegion(self._client_rect) AttributeError: 'RibbonGallery' object has no attribute '_client_rect' --- unittests/test_lib_agw_ribbonbar.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/unittests/test_lib_agw_ribbonbar.py b/unittests/test_lib_agw_ribbonbar.py index 3e27c5a3..98df10bf 100644 --- a/unittests/test_lib_agw_ribbonbar.py +++ b/unittests/test_lib_agw_ribbonbar.py @@ -36,6 +36,22 @@ def CreateBitmap(xpm): class lib_agw_ribbon_Tests(wtc.WidgetTestCase): + def setUp(self): + super(lib_agw_ribbon_Tests, self).setUp() + + self.realRibbonGalleryOnPaint = RB.RibbonGallery.OnPaint + def MonkeyPatchedOnPaint(self, event): pass + RB.RibbonGallery.OnPaint = MonkeyPatchedOnPaint + + self.realRibbonGalleryLayout = RB.RibbonGallery.Layout + def MonkeyPatchedLayout(self): return False + RB.RibbonGallery.Layout = MonkeyPatchedLayout + + def tearDown(self): + super(lib_agw_ribbon_Tests, self).tearDown() + RB.RibbonGallery.OnPaint = self.realRibbonGalleryOnPaint + RB.RibbonGallery.Layout = self.realRibbonGalleryLayout + def test_lib_agw_ribbonCtor(self): rib = RB.RibbonBar(self.frame, wx.ID_ANY, agwStyle=RB.RIBBON_BAR_DEFAULT_STYLE|RB.RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS)