From: Matt N. <new...@ca...> - 2005-03-30 20:41:35
|
Jan, On many lists, asking 'please help me' three times in under twelve hours is liable to get you no help at all, and quite possibly prevent people from helping you in the future. > could anyone show me how to incorporate this example on my GUI? > > what i want to do is to implement this in a wxPanel that is > part of my wxFrame, but i am getting errors that says wxPanel > instance has no attribute GetToolBar... The embedding_in_wx*.py examples didn't help?? The code you posted doesn't have a wxPanel or a wxFrame, so it's difficult to say what the problem might be or what you actually want to do. In general, you can put a FigureCanvasXXX on a wxPanel or wxFrame. A simple example putting a figure on a wxPanel is below. Hope that helps, --Matt import wx from matplotlib.numerix import arange, sin, pi from matplotlib.figure import Figure from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg class PlotPanel(wx.Panel): def __init__(self,parent=None): wx.Panel.__init__(self,parent,-1) self.fig = Figure((5,4), 75) self.canvas = FigureCanvasWxAgg(self,-1,self.fig) self.axes = self.fig.add_axes([0.12,0.12,0.76,0.76]) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas,1, wx.LEFT|wx.TOP) self.SetSizer(sizer) ; self.Fit() def plot(self,x,y): self.axes.cla() self.axes.plot(x,y) class PlotFrame(wx.Frame): def __init__(self,parent=None): wx.Frame.__init__(self,parent,-1,'Frame') self.plotpanel = PlotPanel(self) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(wx.StaticText(self, -1 , ' WX Matplotlib example ') ,0, wx.LEFT|wx.TOP) sizer.Add(self.plotpanel,1, wx.LEFT|wx.TOP) self.SetSizer(sizer) ; self.Fit() def plot(self,x,y): self.plotpanel.plot(x,y) if __name__ == '__main__': app = wx.PySimpleApp() frame = PlotFrame() x = arange(0,10.0,0.025) y = sin(x*pi/2) frame.plot(x,y) frame.Show() app.MainLoop() |