简体   繁体   中英

tkinter window not showing up in Spyder

I am trying to make a simple GUI with tkinter in Spyder 4.2.5 with Python 3.8.8. I have the following code:

import tkinter as tk

window = tk.Tk()

greeting = tk.Label(text='Hello, Tkinter')
greeting.pack()

When I type the code in the command prompt in Windows, a window pops up. HOwever, in Spyder I cannot see it. Is there any setting I need to change or a special output window to check?

Thanks in advance!

Ok, odd, but it seems that in Spyder it needed to add

window.mainloop()

to show up the window, although in command prompt it did not. I hope it helps others!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM