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

Skip to content

Commit 80cb237

Browse files
committed
Regenerate background when RectangleSelector active-flag is set back on.
Otherwise, if the selector is made inactive and then back to active, the "old" selector gets captured in the background image and spurious appears. No tests because good luck with that, but can be tried with examples/widgets/rectangle_selector.py.
1 parent 969513e commit 80cb237

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/matplotlib/widgets.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,6 +2057,23 @@ def __init__(self, ax, onselect, drawtype='box',
20572057

20582058
self._extents_on_press = None
20592059

2060+
def update_background(self, event):
2061+
if not self.useblit:
2062+
return
2063+
# Make sure that widget artists don't get accidentally included in the
2064+
# background, by re-rendering the background if needed (and then
2065+
# re-re-rendering the canvas with the visible widget artists).
2066+
needs_redraw = any(artist.get_visible() for artist in self.artists)
2067+
with ExitStack() as stack:
2068+
if needs_redraw:
2069+
for artist in self.artists:
2070+
stack.callback(artist.set_visible, artist.get_visible())
2071+
artist.set_visible(False)
2072+
self.canvas.draw()
2073+
super().update_background(event)
2074+
if needs_redraw:
2075+
self.update()
2076+
20602077
def _press(self, event):
20612078
"""on button press event"""
20622079
# make the drawn box/line visible get the click-coordinates,

0 commit comments

Comments
 (0)