tkMessageBox returns 'can't invoke "frame" command:' error

tlng at phileo.com.my tlng at phileo.com.my
Mon Jun 21 04:43:44 EDT 1999


import Tkinter
import tkMessageBox

def askyesno():
	if tkMessageBox.askyesno("Testing Askyesno",
				 "Click on something!"):
		print 'You clicked on Yes!';

rootWindow = Tkinter.Tk()

button1 = Tkinter.Button(rootWindow,
			 text="Askyesno",
			 command=askyesno)
button1.pack()

button2 = Tkinter.Button(rootWindow,
			 text="QUIT",
                         command=rootWindow.quit)
button2.pack()

rootWindow.mainloop()



I wrote a script similar to the one shown above. Here are my questions:

1) If I import my script above for the first time, my script runs fine.
However, after I quit my script and try to reload my script at the
Python interpreter by typing reload(myscriptname), I get the error
message: "TclError: Can't invoke "frame" command:". Actually, it is
quite a long-winded error message, I'm just giving the last line.
What's going on and how do I fix this?

2) I even tried including a frame in def askyesno(), like this:

	frame1 = Tkinter.Frame(rootWindow)
	if tkMessageBox.askyesno("Testing Askyesno",
				 "Click on something!"):
		print 'You clicked on Yes!';
	frame1.pack()

However, I still get the same problem. I'm using Tkinter for the first
time and this "Can't invoke "frame" command" error message has been
frustrating me tremendously whenever I try to use one of tkMessageBox's
standard dialogs. I must be doing something wrong, and I would
appreciate it if someone could give some pointers on how to use
tkMessageBox.

3) Also, how do you quit a Tkinter script? Whenever I try to close a Tk
window, I can't get back to the Python interpreter ">>>" prompt.
Instead, my Python shell hangs and I have to do a CTRL-ALT-DEL and
end-task. Surely, there are better ways of closing a Tk window.

I'm running Windows 95 on a Pentium class computer. My Python
interpreter is version 1.5.2 and my Tcl/Tk interpreter is the same one
that is installed automatically by the Python 1.5.2 installer.

Thanks in advance.

Raymond Tong Leng Ng




Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list