From d99430e826dc1ddffb1688b599499cf37f4d1d75 Mon Sep 17 00:00:00 2001 From: Stefan Mitic Date: Tue, 10 Mar 2020 22:58:56 -0400 Subject: [PATCH 1/5] fix: initialize LocationEvent after button def --- lib/matplotlib/backend_bases.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index b17da96dbee9..8186c395a48a 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1394,7 +1394,6 @@ def __init__(self, name, canvas, x, y, button=None, key=None, (*x*, *y*) in figure coords ((0, 0) = bottom left) button pressed None, 1, 2, 3, 'up', 'down' """ - LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) if button in MouseButton.__members__.values(): button = MouseButton(button) self.button = button @@ -1402,6 +1401,9 @@ def __init__(self, name, canvas, x, y, button=None, key=None, self.step = step self.dblclick = dblclick + LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) + + def __str__(self): return (f"{self.name}: " f"xy=({self.x}, {self.y}) xydata=({self.xdata}, {self.ydata}) " From e09cbb7a9c5d4b1e71a1c6bcc0bfefbd1ded62ab Mon Sep 17 00:00:00 2001 From: Stefan Mitic Date: Tue, 31 Mar 2020 13:42:15 -0400 Subject: [PATCH 2/5] style: removed extra blank line --- lib/matplotlib/backend_bases.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 8186c395a48a..e87c33422755 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1403,7 +1403,6 @@ def __init__(self, name, canvas, x, y, button=None, key=None, LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) - def __str__(self): return (f"{self.name}: " f"xy=({self.x}, {self.y}) xydata=({self.xdata}, {self.ydata}) " From d271e4eeadf5d07143d324bfb145d0d0ad700923 Mon Sep 17 00:00:00 2001 From: Stefan Mitic Date: Fri, 3 Apr 2020 17:11:00 -0400 Subject: [PATCH 3/5] fix: changed init for KeyEvent --- lib/matplotlib/backend_bases.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index e87c33422755..72927ae27cdb 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1486,8 +1486,8 @@ def on_key(event): cid = fig.canvas.mpl_connect('key_press_event', on_key) """ def __init__(self, name, canvas, key, x=0, y=0, guiEvent=None): - LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) self.key = key + LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) def _get_renderer(figure, print_method): From 2b2ec2a425b54e849fd243e6371139acce1fe342 Mon Sep 17 00:00:00 2001 From: Stefan Mitic Date: Sat, 4 Apr 2020 19:25:59 -0400 Subject: [PATCH 4/5] fix: added comments to change --- lib/matplotlib/backend_bases.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 72927ae27cdb..7dcf3120dc99 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1401,6 +1401,7 @@ def __init__(self, name, canvas, x, y, button=None, key=None, self.step = step self.dblclick = dblclick + # super-init deferred to the end: callback errors if called before LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) def __str__(self): @@ -1487,6 +1488,7 @@ def on_key(event): """ def __init__(self, name, canvas, key, x=0, y=0, guiEvent=None): self.key = key + # super-init deferred to the end: callback errors if called before LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) From ba42f4099da98c0e94928c997e41eaee02dfd11f Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 9 Jun 2020 16:48:36 -0400 Subject: [PATCH 5/5] DOC: clarify inline comments Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> --- lib/matplotlib/backend_bases.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 7dcf3120dc99..7b60a3125055 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1401,7 +1401,8 @@ def __init__(self, name, canvas, x, y, button=None, key=None, self.step = step self.dblclick = dblclick - # super-init deferred to the end: callback errors if called before + # super-init is deferred to the end because it calls back on + # 'axes_enter_event', which requires a fully initialized event. LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) def __str__(self):