Skip to content

Commit 6062ff6

Browse files
authored
Merge pull request #18219 from jbhopkins/wx_custom_toolbar
Fixes an issue where WxAgg NavigationToolbar2 broke custom toolbars
2 parents bd97b33 + 2abaa0d commit 6062ff6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ def _set_frame_icon(frame):
11081108

11091109

11101110
class NavigationToolbar2Wx(NavigationToolbar2, wx.ToolBar):
1111-
def __init__(self, canvas):
1111+
def __init__(self, canvas, coordinates=True):
11121112
wx.ToolBar.__init__(self, canvas.GetParent(), -1)
11131113

11141114
if 'wxMac' in wx.PlatformInfo:
@@ -1130,9 +1130,11 @@ def __init__(self, canvas):
11301130
self.Bind(wx.EVT_TOOL, getattr(self, callback),
11311131
id=self.wx_ids[text])
11321132

1133-
self.AddStretchableSpace()
1134-
self._label_text = wx.StaticText(self)
1135-
self.AddControl(self._label_text)
1133+
self._coordinates = coordinates
1134+
if self._coordinates:
1135+
self.AddStretchableSpace()
1136+
self._label_text = wx.StaticText(self)
1137+
self.AddControl(self._label_text)
11361138

11371139
self.Realize()
11381140

@@ -1337,7 +1339,8 @@ def statbar(self):
13371339
return self.GetTopLevelParent().GetStatusBar()
13381340

13391341
def set_message(self, s):
1340-
self._label_text.SetLabel(s)
1342+
if self._coordinates:
1343+
self._label_text.SetLabel(s)
13411344

13421345
def set_history_buttons(self):
13431346
can_backward = self._nav_stack._pos > 0

0 commit comments

Comments
 (0)