Skip to content

Commit 1965b09

Browse files
committed
Revert: Deprecate access to Cursor/MultiCursor event handlers.
1 parent 9a2311d commit 1965b09

File tree

2 files changed

+16
-36
lines changed

2 files changed

+16
-36
lines changed

lib/matplotlib/tests/test_widgets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,7 @@ def test_MultiCursor(horizOn, vertOn):
16541654
# Can't use `do_event` as that helper requires the widget
16551655
# to have a single .ax attribute.
16561656
event = mock_event(ax1, xdata=.5, ydata=.25)
1657-
multi._onmove(event)
1657+
multi.onmove(event)
16581658

16591659
# the lines in the first two ax should both move
16601660
for l in multi.vlines:
@@ -1680,7 +1680,7 @@ def test_MultiCursor(horizOn, vertOn):
16801680
# test a move event in an Axes not part of the MultiCursor
16811681
# the lines in ax1 and ax2 should not have moved.
16821682
event = mock_event(ax3, xdata=.75, ydata=.75)
1683-
multi._onmove(event)
1683+
multi.onmove(event)
16841684
for l in multi.vlines:
16851685
assert l.get_xdata() == (.5, .5)
16861686
for l in multi.hlines:

lib/matplotlib/widgets.py

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,8 +1953,8 @@ def __init__(self, ax, horizOn=True, vertOn=True, useblit=False,
19531953
**lineprops):
19541954
super().__init__(ax)
19551955

1956-
self.connect_event('motion_notify_event', self._onmove)
1957-
self.connect_event('draw_event', self._clear)
1956+
self.connect_event('motion_notify_event', self.onmove)
1957+
self.connect_event('draw_event', self.clear)
19581958

19591959
self.visible = True
19601960
self.horizOn = horizOn
@@ -1967,29 +1967,18 @@ def __init__(self, ax, horizOn=True, vertOn=True, useblit=False,
19671967
self.linev = ax.axvline(ax.get_xbound()[0], visible=False, **lineprops)
19681968

19691969
self.background = None
1970-
self._needclear = False
1971-
1972-
needclear = _api.deprecate_privatize_attribute("3.7")
1970+
self.needclear = False
19731971

1974-
@_api.deprecated('3.5')
19751972
def clear(self, event):
1976-
"""Internal event handler to clear the cursor."""
1977-
self._clear(event)
1978-
if self.ignore(event):
1979-
return
1980-
self.linev.set_visible(False)
1981-
self.lineh.set_visible(False)
1982-
1983-
def _clear(self, event):
19841973
"""Internal event handler to clear the cursor."""
19851974
if self.ignore(event):
19861975
return
19871976
if self.useblit:
19881977
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
1978+
self.linev.set_visible(False)
1979+
self.lineh.set_visible(False)
19891980

1990-
onmove = _api.deprecate_privatize_attribute('3.5')
1991-
1992-
def _onmove(self, event):
1981+
def onmove(self, event):
19931982
"""Internal event handler to draw the cursor when the mouse moves."""
19941983
if self.ignore(event):
19951984
return
@@ -1999,11 +1988,11 @@ def _onmove(self, event):
19991988
self.linev.set_visible(False)
20001989
self.lineh.set_visible(False)
20011990

2002-
if self._needclear:
1991+
if self.needclear:
20031992
self.canvas.draw()
2004-
self._needclear = False
1993+
self.needclear = False
20051994
return
2006-
self._needclear = True
1995+
self.needclear = True
20071996

20081997
self.linev.set_xdata((event.xdata, event.xdata))
20091998
self.linev.set_visible(self.visible and self.vertOn)
@@ -2106,8 +2095,8 @@ def connect(self):
21062095
"""Connect events."""
21072096
for canvas, info in self._canvas_infos.items():
21082097
info["cids"] = [
2109-
canvas.mpl_connect('motion_notify_event', self._onmove),
2110-
canvas.mpl_connect('draw_event', self._clear),
2098+
canvas.mpl_connect('motion_notify_event', self.onmove),
2099+
canvas.mpl_connect('draw_event', self.clear),
21112100
]
21122101

21132102
def disconnect(self):
@@ -2117,26 +2106,17 @@ def disconnect(self):
21172106
canvas.mpl_disconnect(cid)
21182107
info["cids"].clear()
21192108

2120-
@_api.deprecated('3.5')
21212109
def clear(self, event):
2122-
"""Clear the cursor."""
2123-
if self.ignore(event):
2124-
return
2125-
self._clear(event)
2126-
for line in self.vlines + self.hlines:
2127-
line.set_visible(False)
2128-
2129-
def _clear(self, event):
21302110
"""Clear the cursor."""
21312111
if self.ignore(event):
21322112
return
21332113
if self.useblit:
21342114
for canvas, info in self._canvas_infos.items():
21352115
info["background"] = canvas.copy_from_bbox(canvas.figure.bbox)
2116+
for line in self.vlines + self.hlines:
2117+
line.set_visible(False)
21362118

2137-
onmove = _api.deprecate_privatize_attribute('3.5')
2138-
2139-
def _onmove(self, event):
2119+
def onmove(self, event):
21402120
if (self.ignore(event)
21412121
or event.inaxes not in self.axes
21422122
or not event.canvas.widgetlock.available(self)):

0 commit comments

Comments
 (0)