# In February 1998, we published an introduction, "Getting # started with Python" , # which included an earlier form of this calc.py. That # version doesn't work properly with Python2.0. This # one does, slightly simplifies the text, and also # brings the window up with focus in the entry widget, # where it belongs. from Tkinter import * def evaluate(): label['text'] = "Result: " + str(eval(expression.get())) frame = Frame(None) entry = Entry(frame) entry['textvariable'] = expression = StringVar() entry.bind("", lambda event: evaluate()) label = Label(frame) button = Button(frame, text = "Submit", command = evaluate) frame.pack() entry.pack() label.pack() button.pack() entry.focus_set() frame.mainloop()