赞
踩
python输入等待10秒钟无输入就跳过继续运行。
可通过提前点击UI,关闭UI即可直接跳过计时,继续运行。
基本无依赖,直接运行源码,测试效果。自行测试之后添加合适的地方即可。
- import tkinter as tk
-
- def countdown(time):
- if time == -1:
- root.destroy()
- else:
- if time == 0:
- label.configure(text="BOOM")
- else:
- label.configure(text="倒计时: %d 秒" % time)
- root.after(1000, countdown, time-1)
-
-
- if __name__=="__main__":
- #设置倒计时间
- root = tk.Tk()
- label = tk.Label(root, width=30)
- label.pack(padx=20, pady=30)
- countdown(10)
- root.mainloop()
-
- print("ok")
运行示例:
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。