30秒倒计时

 1 from tkinter import *
 2 counter = 30
 3 def run_counter(digit):
 4     def counting():
 5         global counter
 6         counter -= 1
 7         digit.config(text=str(counter))
 8         digit.after(1000,counting)
 9     counting()
10 root = Tk()
11 root.title("30秒倒计时")
12 digit=Label(root,bg="yellow",fg="blue",height=3,width=10,font="Helvetic 20 bold")
13 digit.pack()
14 run_counter(digit)
15 
16 root.mainloop()

posted @ 2019-12-02 12:00  做梦者造梦  阅读(432)  评论(0编辑  收藏  举报