# L-30 MCS 260 Mon 5 Nov 2007 : guieval.py # # GUI to evaluation a user given function. from Tkinter import * from math import * top = Tk() top.title("Evaluate Expressions") Label(top,text="f(x) =").grid(row=0) f = Entry(top) f.grid(row=0,column=1) Label(top,text="x =").grid(row=0,column=2) e = Entry(top) e.grid(row=0,column=3) r = Entry(top) r.grid(row=0,column=5) def calc(): "evaluates the function" r.delete(0,END) x = float(e.get()) y = eval(f.get()) r.insert(INSERT,y) b = Button(top,text="equals",command=calc) b.grid(row=0,column=4) top.mainloop()