Reputation:
I have a tkinter window, root
, which should close after a few seconds delay. Here is the code I currently have for my window:
from tkinter import *
root=Tk()
def WaitAndClose():
global root
#close root after a few seconds
Button(root, text='Close', command=WaitAndClose).pack()
mainloop()
EDIT: root.after(,) was the command that worked.
Upvotes: 1
Views: 3804
Reputation: 11
Code:
from tkinter import *
jha=Tk()
jha.title("auto close window")
jha.geometry("750x600")
jha.after(5000,lambda:jha.destroy())
jha.mainloop()
Upvotes: 0
Reputation: 2721
The following should close the tkinter window root
(change as applicable) after 5000 milliseconds (5 seconds):
root.after(5000, root.destroy)
Upvotes: 5