[Tutor] Multiple Tk frames
john at fouhy.net
Tue Feb 13 22:09:44 CET 2007
On 14/02/07, Hazlett, Les <les.hazlett at navteq.com> wrote:
> I have found many simple examples of using Tk with one frame. I found
> self.quit to close the open frame object. I see that control goes to the
> end of main, but I don't know how to then create and use another frame.
In Tkinter parlance, a "Frame" is a container that you use to build up
a window. Is that what you're after, or do you want to make multiple
When you call Tk(), it does two things:
1. it creates a top level window that you can put things into
2. it creates and initialises the Tk engine.
You only need to do (2) once, so you only need to call Tk() once. If
you want more than one top level window, you need to use Toplevel().
from Tkinter import *
root = Tk()
lab1 = Label(root, text="This is the main window")
otherWindow = Toplevel()
lab2 = Label(otherWindow, text="This is the other window")
More information about the Tutor