How it works...

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()
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset