[Tutor] Simple calculator
Joe Cox
jgcox39 at highstream.net
Wed Nov 1 03:37:27 CET 2006
I found this simple calculator on the web:
from Tkinter import *
from math import *
###http://sunsite.uakom.sk/sunworldonline/swol-02-1998/swol-02-python.htmlBy
Cameron Laird and Kathryn Soraiz...Getting Started with Python###
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()
I get this:
>>> Traceback (most recent call last):
File
"D:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
exec codeObject in __main__.__dict__
File "D:\Python24\Calculator\Calc.py", line 12, in ?
entry.bind("", evaluate)
File "D:\Python24\lib\lib-tk\Tkinter.py", line 933, in bind
return self._bind(('bind', self._w), sequence, func, add)
File "D:\Python24\lib\lib-tk\Tkinter.py", line 888, in _bind
self.tk.call(what + (sequence, cmd))
TclError: no events specified in binding
Please have a look for me thanks!
Joe Cox
513-293-4830
More information about the Tutor
mailing list