Why is my tkinter window not showing?
The program runs, prints nothing, and no window appears. Nine times out of ten the loop that keeps the window alive was never started, so Python reaches the end of the file and exits.
import tkinter as tk
root = tk.Tk()
tk.Label(root, text="Hello").pack()
root.mainloop() # without this the window flashes and disappears Anything after mainloop() waits
mainloop() does not return until the window closes, so widgets created below it are never built and any code after it appears not to run. Build everything first, then call it — once, at the end.
IDLE and Jupyter already have a loop
IDLE is itself a tkinter program, and a notebook kernel has its own event handling, so a second mainloop() behaves unpredictably: no window, a frozen one, or a kernel that stops responding. Run GUI scripts from a terminal — python app.py — rather than inside them.
The window exists but you cannot see it
withdraw() hides a window, and deiconify() brings it back — easy to leave in after using it to hide the root behind a dialog. A geometry string with a large offset can also put the window off the edge of the screen, which looks identical to it never opening.
On macOS a window can open behind your editor. root.lift() followed by root.attributes("-topmost", True) proves whether it is there before you go looking for deeper causes.
root.deiconify()
root.lift()
root.geometry("400x300+100+100") # somewhere definitely on screenErrors you never see
Double-clicking a .py file runs it in a console that closes instantly, taking the traceback with it. If a widget line raised, you get no window and no message. Run it from a terminal you opened yourself and the error will be waiting for you.
Doing it without the lookup
The generated main.py always ends with the if __name__ == "__main__": block that creates the window and calls mainloop() exactly once, with every widget built before it — so this particular failure is designed out rather than debugged.
Lay the window out visually and read the generated Python as you go.
Open the tkinter designer →