相关学习内容:
Python Tkinter 绘图项目 - 网易云课堂study.163.comimport time
import tkinter
import threading
root=tkinter.Tk()
root.title('倒计时自动关闭的窗口')
root['width']=400
root['height']=300
root.resizable(False,False)
richText=tkinter.Text(root,width=380)
richText.place(x=10,y=10,width=380,height=230)
richText.insert('0.0','假设阅读这些文字需要10秒钟时间')
lbTime=tkinter.Label(root,fg='red',anchor='w')
lbTime.place(x=10,y=250,width=150)
def autoClose():
for i in range(10):
lbTime['text']='距离窗口关闭还有{}秒'.format(10-i)
time.sleep(1)
root.destroy()
t=threading.Thread(target=autoClose)
t.start()
root.mainloop()
效果图如下:Python Tkinter 绘图项目 - 网易云课堂效果图如下:
![1c6c70d5625883fa5437e14cf31829b0.png](https://img-blog.csdnimg.cn/img_convert/1c6c70d5625883fa5437e14cf31829b0.png)