Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d52cc3d

Browse filesBrowse files
committed
Backport PR #18395: TkAgg bugfix: deselect buttons that are not the current _Mode
Merge pull request #18395 from richardsheridan/multi-toggle-fix FIX: deselect buttons that are not the current _Mode
1 parent bd31143 commit d52cc3d
Copy full SHA for d52cc3d

File tree

Expand file treeCollapse file tree

1 file changed

+18
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-1
lines changed

‎lib/matplotlib/backends/_backend_tk.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/_backend_tk.py
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from matplotlib import backend_tools, cbook
1515
from matplotlib.backend_bases import (
1616
_Backend, FigureCanvasBase, FigureManagerBase, NavigationToolbar2,
17-
StatusbarBase, TimerBase, ToolContainerBase, cursors)
17+
StatusbarBase, TimerBase, ToolContainerBase, cursors, _Mode)
1818
from matplotlib._pylab_helpers import Gcf
1919
from matplotlib.figure import Figure
2020
from matplotlib.widgets import SubplotTool
@@ -538,6 +538,23 @@ def destroy(self, *args):
538538
del self.message
539539
tk.Frame.destroy(self, *args)
540540

541+
def _update_buttons_checked(self):
542+
# sync button checkstates to match active mode
543+
for text, mode in [('Zoom', _Mode.ZOOM), ('Pan', _Mode.PAN)]:
544+
if text in self._buttons:
545+
if self.mode == mode:
546+
self._buttons[text].select() # NOT .invoke()
547+
else:
548+
self._buttons[text].deselect()
549+
550+
def pan(self, *args):
551+
super().pan(*args)
552+
self._update_buttons_checked()
553+
554+
def zoom(self, *args):
555+
super().zoom(*args)
556+
self._update_buttons_checked()
557+
541558
def set_message(self, s):
542559
self.message.set(s)
543560

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.