【发布时间】:2017-08-13 18:13:44
【问题描述】:
我正在尝试制作一个倒计时到特定时间的程序。在这个程序中,我已经分配了我希望它说点击我的时间,但我无法弄清楚如何制作一个倒计时到那个时间的计时器。这是我目前拥有的代码:
import time
from tkinter import *
from datetime import datetime
from threading import Timer
tk = Tk()
canvas = Canvas(tk, width=400, height=400)
canvas.pack()
x = datetime.today()
y = x.replace(day=x.day, hour=1, minute=30, second=0, microsecond=0)
delta_t = y-x
secs = delta_t.seconds+1
def hello_world():
label = Label(tk, text="CLICK NOW", font=('Times', 45), fg='blue')
label.place(relx=0.5, rely=0.5, anchor=CENTER)
t = Timer(secs, hello_world)
t.start()
tk.mainloop()
如果有人对将计时器倒计时到指定时间有任何建议,我们将不胜感激。在此先感谢您的帮助
【问题讨论】:
-
如何将其合并到代码中并保持我现在的概念。我尝试过使用日期时间,但没有成功
-
我阅读了这个问题,但仍然没有答案
标签: python canvas time tkinter timer