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

Skip to content

Commit aa55345

Browse files
committed
Fix rubberbanding on wx+py3.10.
Locally (Arch standard packages), it otherwise fails with File "/usr/lib/python3.10/site-packages/wx/core.py", line 1098, in _DC_DrawLineList return self._DrawLineList(lines, pens, []) TypeError: 'numpy.float64' object cannot be interpreted as an integer
1 parent 1535cdc commit aa55345

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,8 @@ def gui_repaint(self, drawDC=None, origin='WX'):
618618
else self.bitmap)
619619
drawDC.DrawBitmap(bmp, 0, 0)
620620
if self._rubberband_rect is not None:
621-
x0, y0, x1, y1 = self._rubberband_rect
621+
# Some versions of wx+python don't support numpy.float64 here.
622+
x0, y0, x1, y1 = map(int, self._rubberband_rect)
622623
drawDC.DrawLineList(
623624
[(x0, y0, x1, y0), (x1, y0, x1, y1),
624625
(x0, y0, x0, y1), (x0, y1, x1, y1)],

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ def check_alt_backend(alt_backend):
128128
"matplotlib.backends.backend_{}".format(backend))
129129

130130
ax.plot([0, 1], [2, 3])
131+
if fig.canvas.toolbar: # i.e toolbar2.
132+
fig.canvas.toolbar.draw_rubberband(None, 1., 1, 2., 2)
131133

132134
timer = fig.canvas.new_timer(1.) # Test floats casting to int as needed.
133135
timer.add_callback(FigureCanvasBase.key_press_event, fig.canvas, "q")

0 commit comments

Comments
 (0)