The following code works fine under IDLE but errors when run as a standalone:
 
from tkinter import *
root=Tk()
main=Frame(root)
main.grid()
def doit():
    messagebox.showinfo("Hello")
btn1=Button(main,width=10,text="In")
btn1.grid()
lbl1=Label(main)
lbl1.grid()
btn2=Button(main,width=10,text="Out",command=doit)
btn2.grid()
lbl2=Label(main)
lbl2.grid()
root.mainloop()
 
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python33\lib\tkinter\__init__.py", line 1442, in __call__
    return self.func(*args)
  File "C:\Users\Wilson\Documents\Old Documents\My Stuff\Python Pgms\temp.py", l
ine 6, in doit
    messagebox.showinfo("Hello")
NameError: global name 'messagebox' is not defined
 
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to