Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitcb3516a

Browse files
committed
Move emission of axes_enter/leave_event to a separate handler.
1 parent7373c2a commitcb3516a

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

‎lib/matplotlib/backend_bases.py

Lines 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.inaxesiflastisnotNoneelseNone
1351-
iflast_axes!=self.inaxes:
1352-
iflast_axesisnotNone:
1353-
try:
1354-
last.canvas.callbacks.process("axes_leave_event",last)
1355-
exceptException:
1356-
# The last canvas may already have been torn down.
1357-
pass
1358-
ifself.inaxesisnotNone:
1359-
self.canvas.callbacks.process("axes_enter_event",self)
1360-
LocationEvent.lastevent= (
1361-
Noneifself.name=="figure_leave_event"elseself)
1362-
super()._process()
1363-
13641348

13651349
classMouseButton(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.inaxesiflastisnotNoneelseNone
1541+
iflast_axes!=event.inaxes:
1542+
iflast_axesisnotNone:
1543+
try:
1544+
last.canvas.callbacks.process("axes_leave_event",last)
1545+
exceptException:
1546+
# The last canvas may already have been torn down.
1547+
pass
1548+
ifevent.inaxesisnotNone:
1549+
event.canvas.callbacks.process("axes_enter_event",event)
1550+
LocationEvent.lastevent= (
1551+
Noneifevent.name=="figure_leave_event"elseevent)
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
importnumpyasnp
2424

2525
importmatplotlibasmpl
26-
frommatplotlibimport_blocking_input,_docstring,projections
26+
frommatplotlibimport_blocking_input,backend_bases,_docstring,projections
2727
frommatplotlib.artistimport (
2828
Artist,allow_rasterization,_finalize_rasterization)
2929
frommatplotlib.backend_basesimport (
@@ -2260,6 +2260,8 @@ def __init__(self,
22602260
'button_press_event',lambdaevent:self.canvas.pick(event))
22612261
self._scroll_pick_id=self._canvas_callbacks.connect(
22622262
'scroll_event',lambdaevent: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
iffigsizeisNone:
22652267
figsize=mpl.rcParams['figure.figsize']

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp