From 7704b574aa1b994196712b0ce44c1faf13b9e7e9 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Thu, 15 Jun 2023 10:10:15 +0200 Subject: [PATCH] Add missing spacer in tk toolmanager toolbar. Copy-pasted from the NavigationToolbar2 implementation. --- lib/matplotlib/backends/_backend_tk.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/matplotlib/backends/_backend_tk.py b/lib/matplotlib/backends/_backend_tk.py index 0a3fece732c1..ddb4f06ed234 100644 --- a/lib/matplotlib/backends/_backend_tk.py +++ b/lib/matplotlib/backends/_backend_tk.py @@ -972,6 +972,13 @@ def __init__(self, toolmanager, window=None): width=int(width), height=int(height), borderwidth=2) self._label_font = tkinter.font.Font(size=10) + # This filler item ensures the toolbar is always at least two text + # lines high. Otherwise the canvas gets redrawn as the mouse hovers + # over images because those use two-line messages which resize the + # toolbar. + label = tk.Label(master=self, font=self._label_font, + text='\N{NO-BREAK SPACE}\n\N{NO-BREAK SPACE}') + label.pack(side=tk.RIGHT) self._message = tk.StringVar(master=self) self._message_label = tk.Label(master=self, font=self._label_font, textvariable=self._message)