Skip to content

Fix rubberbanding on wx+py3.10. #21990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,8 @@ def gui_repaint(self, drawDC=None, origin='WX'):
else self.bitmap)
drawDC.DrawBitmap(bmp, 0, 0)
if self._rubberband_rect is not None:
x0, y0, x1, y1 = self._rubberband_rect
# Some versions of wx+python don't support numpy.float64 here.
x0, y0, x1, y1 = map(int, self._rubberband_rect)
drawDC.DrawLineList(
[(x0, y0, x1, y0), (x1, y0, x1, y1),
(x0, y0, x0, y1), (x0, y1, x1, y1)],
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_backends_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def check_alt_backend(alt_backend):
"matplotlib.backends.backend_{}".format(backend))

ax.plot([0, 1], [2, 3])
if fig.canvas.toolbar: # i.e toolbar2.
fig.canvas.toolbar.draw_rubberband(None, 1., 1, 2., 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codecov claims this line isn't being tested - is that a CI issue or is the if statement never being executed anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least locally, I can confirm that this is indeed executed...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is run for all backends, and we skip a few, so it seems to be referring to that.


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