Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 752d738

Browse files
committed
WX Monkey patch ClientDC for name changes
DrawRectangleRect has been renamed to DrawRectange. So we monkeypatch the new version to add the old version as an alias
1 parent d8d8a10 commit 752d738

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ def gui_repaint(self, drawDC=None, origin='WX'):
832832
if self.IsShownOnScreen():
833833
if not drawDC:
834834
# not called from OnPaint use a ClientDC
835-
drawDC = wx.ClientDC(self)
835+
drawDC = wxc.ClientDC(self)
836836

837837
# ensure that canvas has no 'left' over stuff when resizing frame
838838
drawDC.Clear()
@@ -1687,7 +1687,7 @@ def release(self, event):
16871687
def draw_rubberband(self, event, x0, y0, x1, y1):
16881688
# Use an Overlay to draw a rubberband-like bounding box.
16891689

1690-
dc = wx.ClientDC(self.canvas)
1690+
dc = wxc.ClientDC(self.canvas)
16911691
odc = wx.DCOverlay(self.wxoverlay, dc)
16921692
odc.Clear()
16931693

@@ -1720,10 +1720,7 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
17201720
r, g, b, a = color.Get(True)
17211721
color.Set(r, g, b, 0x60)
17221722
dc.SetBrush(wx.Brush(color))
1723-
if wxc.is_phoenix:
1724-
dc.DrawRectangle(rect)
1725-
else:
1726-
dc.DrawRectangleRect(rect)
1723+
dc.DrawRectangleRect(rect)
17271724

17281725
def set_status_bar(self, statbar):
17291726
self.statbar = statbar

lib/matplotlib/backends/wx_compat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
print(" wxPython version %s was imported." % backend_version)
2929
raise ImportError(missingwx)
3030

31+
# Import ClientCD so we can Monkey patch it.
32+
ClientDC = wx.ClientDC
33+
3134
if is_phoenix:
3235
# define all the wxPython phoenix stuff
3336

@@ -83,6 +86,8 @@
8386
NamedColour = wx.Colour
8487
StockCursor = wx.Cursor
8588

89+
# Moneypatch ClientDC to for rename of DrawRectangleRect to DrawRectangle
90+
ClientDC.DrawRectangleRect = ClientDC.DrawRectangle
8691
else:
8792
# define all the wxPython classic stuff
8893

0 commit comments

Comments
 (0)