Apr-22-2022, 06:02 PM
Is the top window minimized when you run this:
import tkinter as tk from time import sleep def cancel(win): win.quit() exit(0) def center(win): win.update_idletasks() width = win.winfo_width() frm_width = win.winfo_rootx() - win.winfo_x() win_width = width + 2 * frm_width height = win.winfo_height() titlebar_height = win.winfo_rooty() - win.winfo_y() win_height = height + titlebar_height + frm_width x = win.winfo_screenwidth() // 2 - win_width // 2 y = win.winfo_screenheight() // 2 - win_height // 2 win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) win.deiconify() top = tk.Tk() top.withdraw() sleep(5) tk.Button(top, text="Cancel", command=lambda: cancel(top)).pack(padx=20, pady=20) center(top) top.mainloop()