8000 TkAgg bugfix: deselect buttons that are not the current _Mode by richardsheridan · Pull Request #18395 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

TkAgg bugfix: deselect buttons that are not the current _Mode #18395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from matplotlib import backend_tools, cbook, _c_internal_utils
from matplotlib.backend_bases import (
_Backend, FigureCanvasBase, FigureManagerBase, NavigationToolbar2,
StatusbarBase, TimerBase, ToolContainerBase, cursors)
StatusbarBase, TimerBase, ToolContainerBase, cursors, _Mode)
from matplotlib._pylab_helpers import Gcf
from matplotlib.figure import Figure
from matplotlib.widgets import SubplotTool
Expand Down Expand Up @@ -544,6 +544,23 @@ def __init__(self, canvas, window, *, pack_toolbar=True):
if pack_toolbar:
self.pack(side=tk.BOTTOM, fill=tk.X)

def _update_buttons_checked(self):
# sync button checkstates to match active mode
for text, mode in [('Zoom', _Mode.ZOOM), ('Pan', _Mode.PAN)]:
if text in self._buttons:
if self.mode == mode:
self._buttons[text].select() # NOT .invoke()
else:
self._buttons[text].deselect()

def pan(self, *args):
super().pan(*args)
self._update_buttons_checked()

def zoom(self, *args):
super().zoom(*args)
self._update_buttons_checked()

def set_message(self, s):
self.message.set(s)

Expand Down
0