I may be jumping into this conversation way too late, but I really
like wxmpl. The one bell and whistle that I love is the
click-and-drag box zoom available by default. Attached is my hacked
together simple example of putting a wxmpl.PlotPanel on a wx.notebook.
Ryan
On Nov 27, 2007 11:06 AM, C M <[EMAIL PROTECTED]> wrote:
>
>
>
> On Nov 27, 2007 11:27 AM, Rich Shepard <[EMAIL PROTECTED]> wrote:
> >
> > On Mon, 26 Nov 2007, C M wrote:
> >
> >
> > > Basically what I did (sorry if this is too basic, but I'm pretty new to
> > > this and this may jog others to correct deficiencies in this simple
> > > approach) was to:
> >
> > This is all straightforward and clear. The one statement I've not yet
> > understood is this:
> >
> >
> > > self.graph = matplotFrame3.PlotPanel(self.panel1 ,xpoints,
> ypoints)
> >
> > I assume that matplotFrame3 is the name of the module in which you've
> > written PlotPanel(). Is this assumption correct?
> >
>
> Exactly. That is the module which I mention importing in step 4.
>
> >
> > I'm modifying your approach to suit our application but it seems to be
> the
> > most parsimonious and elegant solution for simple display of plots in a
> > wxPython panel.
> >
> > Thanks,
> >
> >
> >
> >
> Glad it will help your application.
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
#!/usr/bin/env python
import wx
from wxmpl import PlotPanel
from scipy import *
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title,
pos=(150, 150), size=(650, 700))
# Create the menubar
menuBar = wx.MenuBar()
# and a menu
menu = wx.Menu()
# add an item to the menu, using \tKeyName automatically
# creates an accelerator, the third param is some help text
# that will show up in the statusbar
menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit the application")
# bind the menu event to an event handler
self.Bind(wx.EVT_MENU, self.OnTimeToClose, id=wx.ID_EXIT)
# and put the menu on the menubar
menuBar.Append(menu, "&File")
self.SetMenuBar(menuBar)
#create the notebook
self.notebook = wx.Notebook(self, -1, style=0)
#create the first pane for the notebook
self.notebook_pane_1 = wx.Panel(self.notebook, -1)
#create the sizer for the first pane
grid_sizer = wx.FlexGridSizer(2, 1, 0, 0)
#create widgets for pane one
self.PlotPanel = PlotPanel(self.notebook_pane_1, -1)
self.button_1 = wx.Button(self.notebook_pane_1, -1, "button_1")
#add the widgets to pane one's sizer
grid_sizer.Add(self.PlotPanel, 0, 0, 0)
grid_sizer.Add(self.button_1, 0, 0, 0)
self.notebook_pane_1.SetSizer(grid_sizer)
grid_sizer.AddGrowableCol(0)
grid_sizer.AddGrowableRow(0)
#Add pane one to the notebook
self.notebook.AddPage(self.notebook_pane_1, "tab1")
#create the sizer for the main frame
mainsizer = wx.BoxSizer(wx.VERTICAL)
#add the notebook to the sizer
mainsizer.Add(self.notebook, 1, wx.EXPAND, 0)
self.SetSizer(mainsizer)
mainsizer.Fit(self)
self.Layout()
self.InitialPlot()
def InitialPlot(self):
fig = self.PlotPanel.get_figure()
ax = fig.add_subplot(111)
ax.cla()
t = arange(0,1,0.01)
y = sin(2*pi*t)
x = cos(4*pi*t)
ax.plot(t,y,t,x)
ax.set_xlabel('Time (sec)')
ax.set_ylabel('$y(t)$')
def OnTimeToClose(self, evt):
"""Event handler for the button click."""
print "See ya later!"
self.Close()
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, "Simple wxmpl embedding example")
self.SetTopWindow(frame)
#print "Print statements go to this stdout window by default."
frame.Show(True)
return True
if __name__ == "__main__":
app = MyApp(redirect=False)
app.MainLoop()
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users