Creating the main window: Tk().
Creation of the modal window: Toplevel().

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from tkinter import * from tkinter import ttk def popup(): info = Toplevel() # Popup -> Toplevel() info.geometry('200x100') info.title('Hello') ttk.Button(info, text='Quit', command=info.destroy).pack(padx=10, pady=10) info.transient(pack) #Popup reduction impossible info.grab_set() #Interaction with window impossible game pack = Tk() #Main window -> Tk() pack.title('Main window') pack.geometry('300x100') Button(pack, text='Open popup', command=popup).pack(padx=10, pady=10) pack.mainloop() #Only for the main window |
Warning: only one loop mainloop() corresponding to the main window.
The main_window_name.wait_window (popup window_name) method stops the main script until the popup window is closed.
The pop_popup.grab_set () method prevents any interaction with the main window.