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

Skip to content

Commit 29145cf

Browse files
authored
Merge pull request matplotlib#17601 from meeseeksmachine/auto-backport-of-pr-16948-on-v3.2.x
Backport PR matplotlib#16948 on branch v3.2.x (solution: All subclasses of LocationEvent could be used in cbook.callbacks before being fully initialized - issue 15139)
2 parents c4a7cf9 + 8c7dbe1 commit 29145cf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,14 +1420,17 @@ def __init__(self, name, canvas, x, y, button=None, key=None,
14201420
(*x*, *y*) in figure coords ((0, 0) = bottom left)
14211421
button pressed None, 1, 2, 3, 'up', 'down'
14221422
"""
1423-
LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent)
14241423
if button in MouseButton.__members__.values():
14251424
button = MouseButton(button)
14261425
self.button = button
14271426
self.key = key
14281427
self.step = step
14291428
self.dblclick = dblclick
14301429

1430+
# super-init is deferred to the end because it calls back on
1431+
# 'axes_enter_event', which requires a fully initialized event.
1432+
LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent)
1433+
14311434
def __str__(self):
14321435
return (f"{self.name}: "
14331436
f"xy=({self.x}, {self.y}) xydata=({self.xdata}, {self.ydata}) "
@@ -1512,8 +1515,9 @@ def on_key(event):
15121515
cid = fig.canvas.mpl_connect('key_press_event', on_key)
15131516
"""
15141517
def __init__(self, name, canvas, key, x=0, y=0, guiEvent=None):
1515-
LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent)
15161518
self.key = key
1519+
# super-init deferred to the end: callback errors if called before
1520+
LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent)
15171521

15181522

15191523
def _get_renderer(figure, print_method, *, draw_disabled=False):

0 commit comments

Comments
 (0)