Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 65027cf

Browse files
committed
Make wx and wxagg work with wx 2.9.x on Mac.
This affects the wx* backends on OSX only. It removes Mac-specific code that was letting the Frame manage the toolbar directly, without using the Sizer. There was a comment saying that this was needed for OSX 10.3. With wx 2.9.x, however, this method of handling the toolbar does not work at all; no toolbar appears, and the program can hang or otherwise behave erratically. The Sizer method, however, works. The big question is whether the Sizer method works on the Mac with wx 2.8.x. If it does, then this can be merged.
1 parent 616efcf commit 65027cf

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,21 +1506,14 @@ def __init__(self, num, fig):
15061506

15071507
if self.toolbar is not None:
15081508
self.toolbar.Realize()
1509-
if wx.Platform == '__WXMAC__':
1510-
# Mac platform (OSX 10.3, MacPython) does not seem to cope with
1511-
# having a toolbar in a sizer. This work-around gets the buttons
1512-
# back, but at the expense of having the toolbar at the top
1513-
self.SetToolBar(self.toolbar)
1514-
else:
1515-
# On Windows platform, default window size is incorrect, so set
1516-
# toolbar width to figure width.
1517-
tw, th = self.toolbar.GetSizeTuple()
1518-
fw, fh = self.canvas.GetSizeTuple()
1519-
# By adding toolbar in sizer, we are able to put it at the bottom
1520-
# of the frame - so appearance is closer to GTK version.
1521-
# As noted above, doesn't work for Mac.
1522-
self.toolbar.SetSize(wx.Size(fw, th))
1523-
self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
1509+
# On Windows platform, default window size is incorrect, so set
1510+
# toolbar width to figure width.
1511+
tw, th = self.toolbar.GetSizeTuple()
1512+
fw, fh = self.canvas.GetSizeTuple()
1513+
# By adding toolbar in sizer, we are able to put it at the bottom
1514+
# of the frame - so appearance is closer to GTK version.
1515+
self.toolbar.SetSize(wx.Size(fw, th))
1516+
self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
15241517
self.SetSizer(self.sizer)
15251518
self.Fit()
15261519

0 commit comments

Comments
 (0)