I just created a small wxmpl example that I really like (attached),
but when I run it, I get these error messages:
** (python:18091): WARNING **: Can't create printer "PDF" because the
id "PDF" is already used
(python:18091): GnomePrintCupsPlugin-WARNING **: The CUPS printer PDF
could not be created
(python:18091): GnomePrintCupsPlugin-WARNING **: The data for the CUPS
printer PDF could not be loaded.
I don't know if this is wxmpl specific, caused by wxPython, or caused
by matplotlib, but I would like to make it go away. Any thoughts?
Thanks,
Ryan
#!/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