Code on Jupyter failing

My code is failing on Jupyter but on python shell it is working.
This is my code:

tkinter as tk

root = tk.Tk()
root.title("button stuff")
label = tk.Label(root, text = "You are right now in cave, it is very dark and cold. To escape this cave you must pick the correct choices. There is more than one answer to stay alive", font = ('Comic Sans MS', 5), fg = 'Black')

plz tell me what is failing

This is my screen shot

I don’t see anything failing. What you’re missing is likely root.mainloop(), which kicks off the UI.

Thanks for the help

By ‘python shell’, you must mean IDLE’s Shell. Your code works in IDLE, but not the python REPL itself. The reason is discussed in the IDLE doc section 'Developing tkinter applications '. IDLE allows one to interact with a visible tkinter app in a way not possible when mainloop is called.

1 Like