Opening a secondary window
The root Tk
instance represents the main window of our GUI—when it is destroyed, the application quits and the event mainloop finishes.
However, there is another Tkinter class to create additional top-level windows in our application, called Toplevel
. You can use this class to display any kind of window, from custom dialogs to wizard forms.
Getting ready
We will start by creating a simple window that is opened when a button of the main window is clicked. It will contain a button that closes it and returns the focus to the main window:

How to do it...
The Toplevel
widget class creates a new top-level window, which acts as a parent container like the Tk
instance does. Unlike the Tk
class, you can instantiate as many top-level windows as you like:
import tkinter as tk class Window(tk.Toplevel): def __init__(self, parent): super().__init__(parent) self.label = tk.Label(self, text="This is another window") self.button = tk.Button(self, text="Close...