NavigationToolbar2WxAgg Buttons Disappear

Hi All,
I've encountered this problem with the both NavigationToolbar2Wx and the NavigationToolbar2WxAgg.
When I click the Zoom or Pan button the button disappears. The functionality is maintained so if a click the location that the button used to be displayed at the toggle action still works its just that the button is no longer displayed.
Can any one help me fix this?
Thanks
David

Here's the code that demonstrated the problem"

···

######################################
##### Start of Code #################
######################################

#!/usr/bin/env python
# encoding: UTF-8
"""
Basic wxPython App w DrawPanel.py

"""

import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import os
import time
import numpy as np

import matplotlib
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import Toolbar, FigureCanvasWxAgg
from matplotlib.figure import Figure
import pylab as plt
import wx

from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg

class DrawPanel(wx.Panel):
  """ This class constructs a Matplotlib figure and canvas to allow for plots. """
  def __init__(self, parent):
    wx.Panel.__init__(self, parent, -1)
    #Create the widgets
    self.figure = Figure(figsize=(1,1))
    self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
    self.toolbar = NavigationToolbar2WxAgg(self.canvas)
    sizer = wx.BoxSizer(wx.VERTICAL)
    # add to sizer allows resizing
    sizer.Add(self.toolbar, 0, wx.LEFT|wx.TOP)
    sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW)
    self.SetSizer(sizer)
    self.Fit()
    # plot some data
    self.x=np.arange(0,10,.1)
    self.y=plt.sin(self.x)
    self.init_plot()
    
  def init_plot(self):
    self.figure.clf()
    self.ax = self.figure.gca()
    self.ax.plot(self.x, self.y)
    self.canvas.draw()

########################################################################
class MainFrame(wx.Frame):
  """This is the Main Frame"""
  #----------------------------------------------------------------------
  def __init__(self):
    """Constructor"""
    wx.Frame.__init__(self, None, title="Basic wxPython App w DrawPanel",size=(800,600))
    # Create StatusBar
    self.sb=self.CreateStatusBar()
    self.SetStatusText('Basic wxPython App w DrawPanel')
    #------------------------------
    self.Freeze() # need this to prevent flicker during plot resize/redraw
    self.mainpanel = DrawPanel(self)
    self.Layout()
    self.Thaw()
    self.Show()

#----------------------------------------------------------------------
if __name__ == "__main__":
  app = wx.App(False)
  frame = MainFrame()
  app.MainLoop()

######################################
##### End of Code #################
######################################

Which version of matplotlib are you using?

Ben Root

···

On Wednesday, August 15, 2012, David Grudoski wrote:

Hi All,

I’ve encountered this problem with the both NavigationToolbar2Wx and the NavigationToolbar2WxAgg.

When I click the Zoom or Pan button the button disappears. The functionality is maintained so if a click the location that the button used to be displayed at the toggle action still works its just that the button is no longer displayed.

Can any one help me fix this?

Thanks

David

I’m running:
Matplotlib 1.1.0
wxPython 2.9.2.4 osx-carbon (classic)
Python 2.6

on Mac OSX 10.6.8

···

On Aug 15, 2012, at 5:17 AM, Benjamin Root wrote:

On Wednesday, August 15, 2012, David Grudoski wrote:

Hi All,

I’ve encountered this problem with the both NavigationToolbar2Wx and the NavigationToolbar2WxAgg.

When I click the Zoom or Pan button the button disappears. The functionality is maintained so if a click the location that the button used to be displayed at the toggle action still works its just that the button is no longer displayed.

Can any one help me fix this?

Thanks

David

Which version of matplotlib are you using?

Ben Root