From 2abaa0d8dbd6e9bce49aec41abfddfb3c030aa3d Mon Sep 17 00:00:00 2001 From: jbhopkins Date: Tue, 11 Aug 2020 11:56:43 -0500 Subject: [PATCH] Fixes an issue in the wxagg backend where custom subclasses of the NavigationToolbar2 would end up with buttons in the wrong place. --- lib/matplotlib/backends/backend_wx.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index 2296f2877a7c..37d349ad98d7 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -1109,7 +1109,7 @@ def _set_frame_icon(frame): class NavigationToolbar2Wx(NavigationToolbar2, wx.ToolBar): - def __init__(self, canvas): + def __init__(self, canvas, coordinates=True): wx.ToolBar.__init__(self, canvas.GetParent(), -1) if 'wxMac' in wx.PlatformInfo: @@ -1131,9 +1131,11 @@ def __init__(self, canvas): self.Bind(wx.EVT_TOOL, getattr(self, callback), id=self.wx_ids[text]) - self.AddStretchableSpace() - self._label_text = wx.StaticText(self) - self.AddControl(self._label_text) + self._coordinates = coordinates + if self._coordinates: + self.AddStretchableSpace() + self._label_text = wx.StaticText(self) + self.AddControl(self._label_text) self.Realize() @@ -1338,7 +1340,8 @@ def statbar(self): return self.GetTopLevelParent().GetStatusBar() def set_message(self, s): - self._label_text.SetLabel(s) + if self._coordinates: + self._label_text.SetLabel(s) def set_history_buttons(self): can_backward = self._nav_stack._pos > 0