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

Skip to content

Make wx and wxagg work with wx 2.9.x on Mac. #2004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
efiring committed May 24, 2013
commit 65027cfbf0ca1855ab346e78366ce703ff7e01df
23 changes: 8 additions & 15 deletions lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,21 +1506,14 @@ def __init__(self, num, fig):

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

Expand Down