From e7744cf138b11288e4eb7a9913dd79ce8adcc125 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 2 Jan 2022 20:01:58 +0100 Subject: [PATCH] Update both zoom/pan states on wx when triggering from keyboard. Previously, typing "o" and "p" on a wx window would result in both the zoom and the pan button being pressed at the same time. Fix that by relying on the same strategy as all other backends. --- lib/matplotlib/backends/backend_wx.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index a7f35368a0a5..0f74d9441d33 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -1134,15 +1134,19 @@ def _icon(name): def get_canvas(self, frame, fig): return type(self.canvas)(frame, -1, fig) + def _update_buttons_checked(self): + if "Pan" in self.wx_ids: + self.ToggleTool(self.wx_ids["Pan"], self.mode.name == "PAN") + if "Zoom" in self.wx_ids: + self.ToggleTool(self.wx_ids["Zoom"], self.mode.name == "ZOOM") + def zoom(self, *args): - tool = self.wx_ids['Zoom'] - self.ToggleTool(tool, not self.GetToolState(tool)) super().zoom(*args) + self._update_buttons_checked() def pan(self, *args): - tool = self.wx_ids['Pan'] - self.ToggleTool(tool, not self.GetToolState(tool)) super().pan(*args) + self._update_buttons_checked() def save_figure(self, *args): # Fetch the required filename and file type.