Note that there are some explanatory texts on larger screens.

plurals
  1. POMatplotlib ToolBar Icons disappear when selected in wxPython Panel
    primarykey
    data
    text
    <p>I've encountered this behaviour intermittently using the Matplotlib NavigationToolbar2Wx in a Matplotlib Figure canvas in a wx.Frame (or wx.Panel). If the Zoom Icon or Pan Icon are selected the icon disappears however a click in the vacant space still toggles the tool. The Icons for the Home, Backward step or Forward step all behave as expected.</p> <p>Can anyone offer advice on 1. what causes it and 2. how to fix it?</p> <p>Thanks to joaquin for posting the initial code slightly modified to include the toolbar. (http://stackoverflow.com/questions/10737459/embedding-a-matplotlib-figure-inside-a-wxpython-panel)</p> <p>I'm use python 2.6, wxPython 2.9.2.4 osx-carbon (classic) and Matplotlib 1.1.0</p> <p>Thanks</p> <p>The code below shows the problem:</p> <pre><code> #!/usr/bin/env python # encoding: UTF-8 """ wxPython and Matplotlib Canvas with Matplotlib Toolbar.py """ from numpy import arange, sin, pi import matplotlib matplotlib.use('WXAgg') from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure import wx class CanvasPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.figure = Figure() self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(self, -1, self.figure) # Add Matplotlib Toolbar # Add the Matplotlib Navigation toolBar here self.toolbar=NavigationToolbar2Wx(self.canvas) self.toolbar.AddLabelTool(5,'',wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR, (32,32))) #self.Bind(wx.EVT_TOOL, self.NewTitle(), id=5) self.toolbar.Realize() # Add to Box Sizer self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.TOP | wx.GROW) self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(self.sizer) self.Fit() def draw(self): t = arange(0.0, 3.0, 0.01) s = sin(2 * pi * t) self.axes.plot(t, s) if __name__ == "__main__": app = wx.PySimpleApp() fr = wx.Frame(None, title='test',size=(800,600)) panel = CanvasPanel(fr) panel.draw() fr.Show() app.MainLoop() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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