i hav a .py script called letsc.py: (python2.5, matplotlib0.90.1, and py2exe for python 2.5 all on windows xp)
from Tkinter import *
class GUIFramework(Frame):
“”“This is the GUI”""
def __init__(self,master=None):
"""Initialize yourself"""
"""Initialise the base class"""
Frame.__init__(self,master)
"""Set the Window Title"""
self.master.title("Type Some Text")
"""Display the main window"
with a little bit of padding"""
self.grid(padx=10,pady=10)
self.CreateWidgets()
def CreateWidgets(self):
"""Create all the widgets that we need"""
"""Create the Text"""
"""Create the Entry, set it to be a bit wider"""
self.enText1 = Entry(self)
self.enText1.grid(row=0, column=1, columnspan=3)
self.enText2 = Entry(self)
self.enText2.grid(row=1, column=1, columnspan=3)
self.enText3 = Entry(self)
self.enText3.grid(row=2, column=1, columnspan=3)
"""Create the Button, set the text and the
command that will be called when the button is clicked"""
self.btnDisplay = Button(self, text="Display!", command=self.Display)
self.btnDisplay.grid(row=0, column=4)
def Display(self):
from pylab import *
"""Called when btnDisplay is clicked, displays the contents of self.enText"""
t = arange(0.0, 2.0, 0.01)
s = (float(self.enText1.get()))*t*t + (float(self.enText2.get()))*t + (float(self.enText3.get()))
plot(t, s, linewidth=1.0)
xlabel('x (m)')
ylabel('T (K)')
title('The sought after Graph!!!')
grid(True)
show()
if name == “main”:
guiFrame = GUIFramework()
guiFrame.mainloop()
so clearly i use matplotlib… i now use py2exe for distributin wat i made on other XP comps… .sp i make a setup.py as per http://www.py2exe.org/index.cgi/MatPlotLib
from distutils.core import setup
import py2exe
import matplotlib
setup(windows=[‘letsc.py’],
options={
‘py2exe’: {
‘packages’ : [‘matplotlib’, ‘pytz’],
}
},
data_files=[matplotlib.get_py2exe_datafiles()]
)
well i run “python setup.py py2exe” in the console but it finally gives : “error: can’t copy
‘F:\Python25\Lib\site-packages\matplotlib\mpl-data\fonts’ : does’nt
exist or not a regular file” (when actually there is a directory called
mpl-data which has 3 subdirectories … afm, pdfcorefonts and ttf). Build and dist folders are made but thr is no .exe in dist.
so i used this setup :
from distutils.core import setup
import glob
import py2exe
import matplotlib
data = glob.glob(r’F:\Python25\Lib\site-packages\matplotlib*****’)
setup(windows=[“letsc.py”],
options={
‘py2exe’: {
‘packages’ : [‘matplotlib’, ‘pytz’],
}
},
data_files=[("matplotlibdata",data)],
)
Well now it does giv me my letsc.exe but on clicking the display button in it (on which it shud show a graph using matplot) it gives the following error log :
Exception in Tkinter callback
Traceback (most recent call last):
File “Tkinter.pyc”, line 1403, in call
File “letsc.py”, line 49, in Display
File “matplotlib\pylab.pyc”, line 2023, in plot
File “matplotlib\pylab.pyc”, line 937, in ishold
File “matplotlib\pylab.pyc”, line 883, in gca
File “matplotlib\pylab.pyc”, line 893, in gcf
File “matplotlib\pylab.pyc”, line 859, in figure
File “matplotlib\backends\backend_tkagg.pyc”, line 90, in new_figure_manager
File “matplotlib\backends\backend_tkagg.pyc”, line 274, in init
File “matplotlib\backends\backend_tkagg.pyc”, line 545, in init
File “matplotlib\backend_bases.pyc”, line 1163, in init
File “matplotlib\backends\backend_tkagg.pyc”, line 590, in _init_toolbar
File “matplotlib\backends\backend_tkagg.pyc”, line 573, in _Button
File “Tkinter.pyc”, line 3270, in init
File “Tkinter.pyc”, line 3226, in init
TclError: couldn’t open “F:\Python25\dist\matplotlibdata\images\home.ppm”: no such file or directory
so basically after a lot of efforts its frustrating… so any help appreciated… thanx