Skip to content

Regenerate background when RectangleSelector active-flag is set back on. #17480

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
Oct 2, 2020
Merged
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
15 changes: 14 additions & 1 deletion lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,8 +1456,21 @@ def update_background(self, event):
"""Force an update of the background."""
# If you add a call to `ignore` here, you'll want to check edge case:
# `release` can call a draw event even when `ignore` is True.
if self.useblit:
if not self.useblit:
return
# Make sure that widget artists don't get accidentally included in the
# background, by re-rendering the background if needed (and then
# re-re-rendering the canvas with the visible widget artists).
needs_redraw = any(artist.get_visible() for artist in self.artists)
with ExitStack() as stack:
if needs_redraw:
for artist in self.artists:
stack.callback(artist.set_visible, artist.get_visible())
artist.set_visible(False)
self.canvas.draw()
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
if needs_redraw:
self.update()

def connect_default_events(self):
"""Connect the major canvas events to methods."""
Expand Down