Skip to content

Commit 43a4c2b

Browse files
authored
Merge pull request #16948 from Stefan-Mitic/issue/15139
solution: All subclasses of LocationEvent could be used in cbook.callbacks before being fully initialized - issue 15139
2 parents 20da503 + ba42f40 commit 43a4c2b

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
@@ -1407,14 +1407,17 @@ def __init__(self, name, canvas, x, y, button=None, key=None,
14071407
(*x*, *y*) in figure coords ((0, 0) = bottom left)
14081408
button pressed None, 1, 2, 3, 'up', 'down'
14091409
"""
1410-
LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent)
14111410
if button in MouseButton.__members__.values():
14121411
button = MouseButton(button)
14131412
self.button = button
14141413
self.key = key
14151414
self.step = step
14161415
self.dblclick = dblclick
14171416

1417+
# super-init is deferred to the end because it calls back on
1418+
# 'axes_enter_event', which requires a fully initialized event.
1419+
LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent)
1420+
14181421
def __str__(self):
14191422
return (f"{self.name}: "
14201423
f"xy=({self.x}, {self.y}) xydata=({self.xdata}, {self.ydata}) "
@@ -1498,8 +1501,9 @@ def on_key(event):
14981501
cid = fig.canvas.mpl_connect('key_press_event', on_key)
14991502
"""
15001503
def __init__(self, name, canvas, key, x=0, y=0, guiEvent=None):
1501-
LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent)
15021504
self.key = key
1505+
# super-init deferred to the end: callback errors if called before
1506+
LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent)
15031507

15041508

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy