calculator.py help

dijkhuis at my-deja.com dijkhuis at my-deja.com
Tue Nov 14 09:04:17 CET 2000


Hello,

Can someone please help me with the following code?
I found this example somewhere but it won't work.
It is supposed to be a calculator.
Thanks,

Dijkhuis
------

from Tkinter import *
from math import *

def evaluate(event):
    label['text']="result: " + str(eval(expression.get()))

frame = Frame(None)

entry = Entry(frame)
entry['textvariable'] = expression = StringVar()
entry.bind("",evaluate)

label = Label(frame)

button = Button(frame, text = "Submit", command = evaluate)

frame.pack()
entry.pack()
label.pack()
button.pack()
frame.mainloop()


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list