What is the proper way to cancel a window so I do not get the error 'command ".window" already exists in namespace"::" ' if I try to open it again later?
By "cancelling" a window, I assume you mean "destroy" it? The destroy command completely destroys one or more widgets. It also destroys any children of that widget (for example, other widgets managed by a frame). As you've seen, Tcl requires all widgets to have unique names, so it's an error to create a widget with the name of an existing widget.
By the way, if you've got a widget or toplevel window that you want to display and hide repeatedly in a program, you don't have to destroy it; you can instead temporarily hide it. The pack forget and grid forget commands remove from the screen a widget previously packed or gridded. You can then pack or grid them again later without having to recreate them from scratch. And for a toplevel window, you can use wm withdraw to hide it and wm deiconify to redisplay it. - Ken Jones, President
Avia Training and Consulting
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.