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

Skip to content

Commit e7744cf

Browse files
committed
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.
1 parent 1708956 commit e7744cf

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,15 +1134,19 @@ def _icon(name):
11341134
def get_canvas(self, frame, fig):
11351135
return type(self.canvas)(frame, -1, fig)
11361136

1137+
def _update_buttons_checked(self):
1138+
if "Pan" in self.wx_ids:
1139+
self.ToggleTool(self.wx_ids["Pan"], self.mode.name == "PAN")
1140+
if "Zoom" in self.wx_ids:
1141+
self.ToggleTool(self.wx_ids["Zoom"], self.mode.name == "ZOOM")
1142+
11371143
def zoom(self, *args):
1138-
tool = self.wx_ids['Zoom']
1139-
self.ToggleTool(tool, not self.GetToolState(tool))
11401144
super().zoom(*args)
1145+
self._update_buttons_checked()
11411146

11421147
def pan(self, *args):
1143-
tool = self.wx_ids['Pan']
1144-
self.ToggleTool(tool, not self.GetToolState(tool))
11451148
super().pan(*args)
1149+
self._update_buttons_checked()
11461150

11471151
def save_figure(self, *args):
11481152
# Fetch the required filename and file type.

0 commit comments

Comments
 (0)