We define a Toplevel subclass to represent our custom window, whose relationship with the parent window is defined in its __init__ method. Widgets are added to this window as usual, since we are following the same conventions as when we subclass Tk:
class Window(tk.Toplevel):
def __init__(self, parent):
super().__init__(parent)
The window is opened by simply creating a new instance, but in order to make it receive all the events, we have to call its grab_set method. This prevents users from interacting with the main window until this one is closed:
def open_window(self):
window = Window(self)
window.grab_set()