Note that there are some explanatory texts on larger screens.

plurals
  1. POmatplotlib navtoolbar doesn't realize in wx 2.9 (Mac OS X)
    primarykey
    data
    text
    <p>The following piece of code produces a matplotlib NavToolbar2 at the top of a frame as expected when run on wxPython 2.8.x, Python 2.5.4/2.6, Matplotlib 0.99.x.</p> <p>However, I've recently moved to Python 2.7, and wxPython 2.9.1 in an attempt to support OS X in 64-bit. It's under this environment that the code below produces an empty toolbar:</p> <p><img src="https://i.stack.imgur.com/zefAB.png" alt="empty toolbar"></p> <p>I noticed when building matplotlib that it said something about not needing WxAgg for wx 2.9 and up, might this be the problem? All I've tried so far is to replace <code>FigureCanvasWxAgg</code> with <code>FigureCanvasWx</code> and <code>NavigationToolbar2WxAgg</code> with <code>NavigationToolbar2Wx</code>. No luck.</p> <p>Any ideas what's going on?</p> <pre><code>import wx from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg, NavigationToolbar2WxAgg import matplotlib as mpl app = wx.PySimpleApp() f = wx.Frame(None) fig = mpl.figure.Figure() p = FigureCanvasWxAgg(f, -1, fig) tb = NavigationToolbar2WxAgg(fig.canvas) f.SetToolBar(tb) tb.Realize() f.Show() app.MainLoop() </code></pre> <p>One more thing... if I replace the NavigationToolbar2WxAgg with my own custom navtoolbar class (code at first answer on this thread: <a href="https://stackoverflow.com/questions/4740988/add-new-navigate-modes-in-matplotlib">Add new navigate modes in matplotlib</a>), the whole thing crashes unless I remove <code>tb.Realize()</code>.</p> <pre><code>2011-05-25 08:21:18.354 Python[48013:60f] *** Assertion failure in -[NSToolbar _itemAtIndex:], /SourceCache/AppKit/AppKit-1038.35/Toolbar.subproj/NSToolbar.m:1227 2011-05-25 08:21:18.356 Python[48013:60f] An uncaught exception was raised 2011-05-25 08:21:18.356 Python[48013:60f] Invalid parameter not satisfying: index&gt;=0 &amp;&amp; index&lt;[self _numberOfItems] 2011-05-25 08:21:18.358 Python[48013:60f] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: index&gt;=0 &amp;&amp; index&lt;[self _numberOfItems]' *** Call stack at first throw: ( 0 CoreFoundation 0x00007fff868ef7b4 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x00007fff83e9b0f3 objc_exception_throw + 45 2 CoreFoundation 0x00007fff868ef5d7 +[NSException raise:format:arguments:] + 103 3 Foundation 0x00007fff86d7c77e -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198 4 AppKit 0x00007fff806f44a9 -[NSToolbar _itemAtIndex:] + 158 5 AppKit 0x00007fff806f3e94 -[NSToolbar _removeItemAtIndex:notifyDelegate:notifyView:notifyFamilyAndUpdateDefaults:] + 56 6 libwx_osx_cocoau-2.9.1.0.0.dylib 0x0000000101aea2a6 _ZN9wxToolBar7RealizeEv + 1430 7 _controls_.so 0x00000001048d4b76 _wrap_ToolBarBase_Realize + 102 8 .Python 0x00000001000ca81a PyEval_EvalFrameEx + 23498 9 .Python 0x00000001000cc8c5 PyEval_EvalCodeEx + 1733 10 .Python 0x00000001000ca9bf PyEval_EvalFrameEx + 23919 11 .Python 0x00000001000cc8c5 PyEval_EvalCodeEx + 1733 12 .Python 0x00000001000cb0c8 PyEval_EvalFrameEx + 25720 13 .Python 0x00000001000cc8c5 PyEval_EvalCodeEx + 1733 14 .Python 0x00000001000ca9bf PyEval_EvalFrameEx + 23919 15 .Python 0x00000001000cb2a6 PyEval_EvalFrameEx + 26198 16 .Python 0x00000001000cb2a6 PyEval_EvalFrameEx + 26198 17 .Python 0x00000001000cc8c5 PyEval_EvalCodeEx + 1733 18 .Python 0x00000001000ca9bf PyEval_EvalFrameEx + 23919 19 .Python 0x00000001000cb2a6 PyEval_EvalFrameEx + 26198 20 .Python 0x00000001000cc8c5 PyEval_EvalCodeEx + 1733 21 .Python 0x00000001000ccbc6 PyEval_EvalCode + 54 22 .Python 0x00000001000f0c7e PyRun_FileExFlags + 174 23 .Python 0x00000001000f1aa1 PyRun_SimpleFileExFlags + 817 24 .Python 0x00000001001093d9 Py_Main + 2825 25 Python 0x0000000100000f54 0x0 + 4294971220 ) terminate called after throwing an instance of 'NSException' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload