from Tkinter import *
from math import *
def calc():
result = "= " + str(eval(expression.get()))
label.config(text = result)
root = Tk()
frame = Frame(root)
label = Label(frame)
entry = Entry(frame)
expression = StringVar()
entry["textvariable"] = expression
button = Button(frame, text = "=", command = calc)
frame.pack()
entry.pack()
label.pack(side=LEFT)
button.pack(side=RIGHT)
frame.mainloop()
|