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

tlng at phileo.com.my tlng at phileo.com.my
Thu Jun 24 05:43:12 EDT 1999


In article <c75so7lklce.fsf at pc142.cosc.canterbury.ac.nz>,
  Timothy R Evans <tre17 at cosc.canterbury.ac.nz> wrote:
> The actuall error is caused by the Tk mainloop cannot be restarted,
> obviously Tkinter was never designed to support what you're doing
> here.

Oh, you mean I can't reload my script if my script contains Tkinter
calls? How do you test your Tkinter scripts then? What I usually do is,
I write my Python script in a text editor, switch to the Python
interpreter and reload my script to see if my script is working. Since
I can't do this with Tkinter scripts, does that mean everytime I want
to retest my Tkinter scripts, I have to quit Python and restart Python?

> The cause of your problem seems be partly that you actually
> expected this to work, putting lots of code in a module
> initialisation is not good style.

That bit about "putting lots of code in a module initialisation" just
went over my head. What did I do that constitutes "module
initialisation"? I've reposted my sample script below so you can point
it out to me easily.

-----
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()
-----

> If you post a description of what you are trying
> to do I can give you a correct and better style solution.
>
> --
> Tim Evans

What I'm trying to do is pretty simple. I want to display a menu of
several buttons. When Button1 is clicked, it will use Windows Notepad
to open a text file and display a askyesno dialog box. If user is
satisfied with what he sees in the text file, he clicks yes and the
file will be uploaded to a server. If not, program quits. Clicking on
Button2 will open up another menu of several buttons which will run
other scripts. All the other buttons are variations of the above and
all the scripts to be called by the buttons have already by written. I
just need to write the Tkinter menu screen. I chose to use
tkMessageBox's standard dialogs because I'm new to Tkinter and the
standard dialogs pretty much cover what I need.

Thanks for your post, Tim

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