On Fri, Oct 3, 2008 at 8:31 PM,  <[EMAIL PROTECTED]> wrote:
> 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.

The way I would do this is to have the class containing the button
handler save a reference to the window. When the window is closed then
set the reference to None. Then the button handler can check to see if
it already has a window.

Alternately you could just create a single, hidden window at startup,
then the button shows the window and the close box just hides it
instead of destroying it.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to