here is the whole code: from __future__ import division import Tkinter from Tkinter import *
mygui = Tkinter.Tk() mygui.title("Calculator") w = Label(mygui, text="Answer: ") w.place(relx=0.15, rely=0.1, anchor=CENTER) nbr = "" def Disp(nstr): global nbr nbr=nbr+nstr print "You need to seek help!",nbr def Calc(): global nbr try: print eval(nbr) #a = Label(mygui, text=eval(nbr)) #a.place(relx=0.4, rely=0.1, anchor=CENTER) except: print "Not computable" nbr = "" def Erase(): global nbr nbr = "" b = Button(mygui, text="1",command=lambda n='1':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.2, anchor=CENTER) b = Button(mygui, text="2",command=lambda n='2':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.2, anchor=CENTER) b = Button(mygui, text="3",command=lambda n='3':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.2, anchor=CENTER) b = Button(mygui, text="+",command=lambda n='+':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.2, anchor=CENTER) b = Button(mygui, text="4",command=lambda n='4':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.3, anchor=CENTER) b = Button(mygui, text="5",command=lambda n='5':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.3, anchor=CENTER) b = Button(mygui, text="6",command=lambda n='6':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.3, anchor=CENTER) b = Button(mygui, text="-",command=lambda n='-':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.3, anchor=CENTER) b = Button(mygui, text="7",command=lambda n='7':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.4, anchor=CENTER) b = Button(mygui, text="8",command=lambda n='8':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.4, anchor=CENTER) b = Button(mygui, text="9",command=lambda n='9':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.4, anchor=CENTER) b = Button(mygui, text="*",command=lambda n='*':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.4, anchor=CENTER) b = Button(mygui, text="0",command=lambda n='0':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.5, anchor=CENTER) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.2, rely=0.5, anchor=CENTER) b = Button(mygui, text="^.5",command=lambda n='**.5':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.5, anchor=CENTER) b = Button(mygui, text="/",command=lambda n='/':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.5, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=2, height=1) b.place(relx=0.2, rely=0.7, anchor=CENTER) mygui.mainloop() -- http://mail.python.org/mailman/listinfo/python-list