Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cb3516a

Browse filesBrowse files
committed
Move emission of axes_enter/leave_event to a separate handler.
1 parent 7373c2a commit cb3516a
Copy full SHA for cb3516a

File tree

Expand file treeCollapse file tree

2 files changed

+19
-17
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-17
lines changed

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+16-16Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,22 +1345,6 @@ def __init__(self, name, canvas, x, y, guiEvent=None):
13451345
self.xdata = xdata
13461346
self.ydata = ydata
13471347

1348-
def _process(self):
1349-
last = LocationEvent.lastevent
1350-
last_axes = last.inaxes if last is not None else None
1351-
if last_axes != self.inaxes:
1352-
if last_axes is not None:
1353-
try:
1354-
last.canvas.callbacks.process("axes_leave_event", last)
1355-
except Exception:
1356-
# The last canvas may already have been torn down.
1357-
pass
1358-
if self.inaxes is not None:
1359-
self.canvas.callbacks.process("axes_enter_event", self)
1360-
LocationEvent.lastevent = (
1361-
None if self.name == "figure_leave_event" else self)
1362-
super()._process()
1363-
13641348

13651349
class MouseButton(IntEnum):
13661350
LEFT = 1
@@ -1551,6 +1535,22 @@ def _process(self):
15511535
super()._process()
15521536

15531537

1538+
def _axes_enter_leave_emitter(event):
1539+
last = LocationEvent.lastevent
1540+
last_axes = last.inaxes if last is not None else None
1541+
if last_axes != event.inaxes:
1542+
if last_axes is not None:
1543+
try:
1544+
last.canvas.callbacks.process("axes_leave_event", last)
1545+
except Exception:
1546+
# The last canvas may already have been torn down.
1547+
pass
1548+
if event.inaxes is not None:
1549+
event.canvas.callbacks.process("axes_enter_event", event)
1550+
LocationEvent.lastevent = (
1551+
None if event.name == "figure_leave_event" else event)
1552+
1553+
15541554
def _get_renderer(figure, print_method=None):
15551555
"""
15561556
Get the renderer that would be used to save a `.Figure`, and cache it on

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import numpy as np
2424

2525
import matplotlib as mpl
26-
from matplotlib import _blocking_input, _docstring, projections
26+
from matplotlib import _blocking_input, backend_bases, _docstring, projections
2727
from matplotlib.artist import (
2828
Artist, allow_rasterization, _finalize_rasterization)
2929
from matplotlib.backend_bases import (
@@ -2260,6 +2260,8 @@ def __init__(self,
22602260
'button_press_event', lambda event: self.canvas.pick(event))
22612261
self._scroll_pick_id = self._canvas_callbacks.connect(
22622262
'scroll_event', lambda event: self.canvas.pick(event))
2263+
self._axes_enter_leave_id = self._canvas_callbacks.connect(
2264+
'motion_notify_event', backend_bases._axes_enter_leave_emitter)
22632265

22642266
if figsize is None:
22652267
figsize = mpl.rcParams['figure.figsize']

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.