import sys, threading, tkinter,time def stop(window): # window.destroy() window.quit() sys.exit(0) window = tkinter.Tk() window.title(‘invariant!‘) window.geometry(‘800x600‘) window.attributes(‘-topmost‘,True) label = tkinter.Label(window, text=‘Xanadu‘, bg=‘green‘, font=(‘Arial‘, 22), width=30, height=40) label.pack() # label.place() # threading.Thread(target=window.mainloop,name=‘tkinter‘).start() threading.Timer(interval=5, function=stop, args=[window]).start() window.mainloop()
原文:https://www.cnblogs.com/dissipate/p/14695308.html