From e3d2166cfe5272aff2c89d30e18327c04a7835d3 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 18 Jul 2018 13:10:02 -0400 Subject: [PATCH] Backport PR #11694: moving toolmanager initialization up before toolbar --- lib/matplotlib/backends/_backend_tk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/_backend_tk.py b/lib/matplotlib/backends/_backend_tk.py index 24bbfe955a68..da404b6e1bc7 100644 --- a/lib/matplotlib/backends/_backend_tk.py +++ b/lib/matplotlib/backends/_backend_tk.py @@ -472,12 +472,13 @@ def __init__(self, canvas, num, window): self.window.withdraw() self.set_window_title("Figure %d" % num) self.canvas = canvas + # If using toolmanager it has to be present when initializing the toolbar + self.toolmanager = self._get_toolmanager() # packing toolbar first, because if space is getting low, last packed widget is getting shrunk first (-> the canvas) self.toolbar = self._get_toolbar() self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) self._num = num - self.toolmanager = self._get_toolmanager() self.statusbar = None if self.toolmanager: