[Tutor] destroying windows

Alan Gauld alan.gauld at btinternet.com
Mon Jun 30 22:18:08 CEST 2008

"Jim Morcombe" <jmorcombe at westnet.com.au> wrote

> If the user selects an option, then I want to destroy that window 
> and then display a second window.
> In turn, the user can select an option to change back to the first 
> window and I want to destroy that window and then display the first 
> again.

You probably don't want to destroy the windows but merely hide
them. That way you can keep the state alive and its also less
resource hungry and more performant. There should be hide and
show (or draw/paint?) methods for Tkinter windows I believe.

However, I will say that that style of GUI is very disconcerting to
the user and goes against every published UI style guide I've ever
seen. It's more normal to have a parent window and display dialogs.
That way the basic window remains as a kind of terms of reference
for the user. It will also play better with things like the Windows
Task bar and MacOS Dock. You can then put the control logic
in the parent window so that it knows which dialog is being
displayed and can show the next one (and there could be many
more than 2 to choose from!) depending on the return value from
the active dialog. The window need not be big (eg xman) but it
just provides a continuity of interface to the user.


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list