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

Skip to content

Commit a2540ac

Browse files
committed
Add internal method to clear without update to simplify code
1 parent 54f274a commit a2540ac

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/matplotlib/widgets.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,9 +2072,12 @@ def visible(self, visible):
20722072

20732073
def clear(self):
20742074
"""Clear the selection and set the selector ready to make a new one."""
2075+
self._clear_without_update()
2076+
self.update()
2077+
2078+
def _clear_without_update(self):
20752079
self._selection_completed = False
20762080
self.set_visible(False)
2077-
self.update()
20782081

20792082
@property
20802083
def artists(self):
@@ -3092,12 +3095,10 @@ def _release(self, event):
30923095
# either x or y-direction
30933096
minspanxy = (spanx <= self.minspanx or spany <= self.minspany)
30943097
if (self._drawtype != 'none' and minspanxy):
3095-
for artist in self.artists:
3096-
artist.set_visible(False)
30973098
if self._selection_completed:
30983099
# Call onselect, only when the selection is already existing
30993100
self.onselect(self._eventpress, self._eventrelease)
3100-
self._selection_completed = False
3101+
self._clear_without_update()
31013102
else:
31023103
self.onselect(self._eventpress, self._eventrelease)
31033104
self._selection_completed = True

0 commit comments

Comments
 (0)