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'
This commit is contained in:
James Wettenhall
2017-03-23 21:59:09 +11:00
parent ff677ea1d5
commit 15eca0a399

View File

@@ -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)