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

Skip to content

Commit 1e15cd4

Browse files
update button state regardless of pan/zoom caller
modest redundancy on click
1 parent 8fa8204 commit 1e15cd4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,11 +546,12 @@ def __init__(self, canvas, window, *, pack_toolbar=True):
546546

547547
def _update_buttons_checked(self):
548548
# sync button checkstates to match active mode
549-
# Tk Checkbuttons only need to be switched off manually
550-
# if mode was changed by some other button
551549
for text, mode in [('Zoom', _Mode.ZOOM), ('Pan', _Mode.PAN)]:
552-
if self.mode != mode:
553-
self._buttons[text].deselect()
550+
if text in self._buttons:
551+
if self.mode == mode:
552+
self._buttons[text].select() # NOT .invoke()
553+
else:
554+
self._buttons[text].deselect()
554555

555556
def pan(self, *args):
556557
super().pan(*args)

0 commit comments

Comments
 (0)