I'm creating a game which runs fine but when I close the window it gives this error:
_tkinter.TclError: can't invoke "update" command: application has been destroyed error
To fix it, I added this code, which I got from another question asked here, before the while loop.
x = True
def update_x():
global x
x = False
tk.protocol("WM_DELETE_WINDOW", update_x)
The while loop is:
while x == True:
draw()
time.sleep(0.1)
tk.update()
The window doesn't close at all now. What am I doing wrong?
I don't really know how to use the mainloop method, is there any way to make it work using the while loop above?
question from:
https://stackoverflow.com/questions/65840120/tkinter-window-not-closing 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…