ExoticBirdsMerchant
ExoticBirdsMerchant

Reputation: 1536

Can't close a tkinter window

If i run it it will open the blue window but destroy() will not close the window. How can i fix it with a commant that closes it? Internet resources point to the destroy() comand which doesnt function.

Although i know that mainloop keeps the window alive when i try to exit it using destroyit just doesn't work.

from tkinter import *
import time


my_window = Tk()
my_window.title('Lang')
my_window.configure(background= 'blue')
#time.sleep(1)
my_window.mainloop()

my_window.withdraw()
my_window.destroy()

Upvotes: 0

Views: 840

Answers (1)

user11111136
user11111136

Reputation:

You need to put the mainloop at the end of your code.

from tkinter import *
import time


my_window = Tk()
my_window.title('Lang')
my_window.configure(background= 'blue')
#time.sleep(1)

my_window.withdraw()
my_window.destroy()

my_window.mainloop()

Upvotes: 1

Related Questions