Lino Website

surf notes

Tkinter basics

Tuesday, 21. February 2006 09:58.

Michael Lange wrote a good introduction to Tk() and Toplevel() in a thread about Tkinter on the mailing list:

Tk() is the application's main (or root) window; any Tkinter app needs a Tk() window as parent for all the other widgets. That's why you have to call the mainloop() for your Tk() window to keep the whole thing alive. The toplevel widget (called with the Toplevel() command) is a window that looks just like the Tk() window, but is in fact a child of the mainwindow. You don't need to call a mainloop() on Toplevel() windows. When you close your mainwindow the children Toplevel windows are closed as well, but not vice versa. Toplevel windows are used for things like dialog boxes or in complex guis where you need more than one window.

Copyright 2001-2007 Luc Saffre.
Generated 2007-06-07 16:22:38