[Tutor] keep from opening multiple Toplevel windows

dwbarne at earthlink.net dwbarne at earthlink.net
Sat Oct 4 02:31:21 CEST 2008


I have a Tkinter button widget that when pressed invokes a Toplevel window call each time. The Toplevel window thus generated has a close button on it. As you might guess, when multiple Toplevel windows are open, I can press on a 'close' button to '.destroy' the window, but all other Toplevel windows remain and do not respond to their 'close' buttons. I understand why THIS happens, but...

The behavior I seek is that one and only one Toplevel window gets generated no matter how many times the original Tkinter button is pressed. A new Toplevel is generated only after the previous one is closed.

My question is: how does one check that a particular Toplevel window is open? I've tried just checking on the Toplevel widget name with try-except, but the value of the Toplevel name stays persistent even when the .destroy method is used to kill the Toplevel window, which makes try-except think the Toplevel is still open. 


More information about the Tutor mailing list