我需要在猕猴桃中创建一个60秒的倒数计时器。它将在代码运行时立即开始,并且当倒数为0时应显示“倒数完成”。
尚未能够为此导出任何代码。我只需要一个简单的60秒倒数计时器
答案 0 :(得分:-2)
这是使用Tkinter开发的,
from tkinter import *
import time, sys
window = Tk()
window.title("Countdown")
print('\nHello\nInstructions: add time.\n')
hourz = input('Hours: ')
minz = input('Minutes: ')
secz = input('Seconds: ')
hour = int(hourz); min = int(minz); sec = int(secz)
var = StringVar()
var.set("00:00:00")
label_title = Label(window, textvariable=var)
label_title.pack()
window.update()
print('Check the window !\n')
while hour > -1:
while min > -1:
while sec > 0:
sec = sec - 1
time.sleep(1)
sec1 = ('%02.f' % sec) # format
min1 = ('%02.f' % min)
hour1 = ('%02.f' % hour)
var.set('\r' + str(hour1) + ' : ' + str(min1) + ' : ' + str(sec1))
window.update()
min = min - 1
sec = 60
hour = hour - 1
min = 59
print(' Finish !\n')
window.mainloop()