[Tutor] login window using Tk
alan.gauld at btinternet.com
Tue Nov 1 19:02:59 CET 2011
On 01/11/11 16:47, Chris Hare wrote:
> I am working on a python Tk program which involves a login window and I
> am looking for some advice.
> Currently the code I have creates a window (Toplevel) where the login
> controls are and I am running that using a main loop for the window.
Don't do this, it is frought with difficulties. Have a single
mainloop for the program. Everything else should be driven by
So you initialise your program including creating both the main and
login windows. You show the login window. When the user logs in you
validate the login and if not valid return control to the login window.
If it is valid close the login window and show the main window.
You then proceed to process all events for the main window.
Trying to synchronize and control multiple mainloops in a GUI
environment is incredibly hard to get right.
Author of the Learn to Program web site
More information about the Tutor