如何在GUI上显示每周倒数计时器?

时间:2019-07-12 22:26:16

标签: python pyqt5

我想知道如何像在某些网站上看到的那样在GUI上显示倒数计时器。我是否为此使用显示小部件?下面的代码是我打算在GUI上显示的内容。

import datetime
import time

set_Date = datetime.date.today()

while set_Date.weekday() != 4:
    set_Date += datetime.timedelta(1)

yr = int(set_Date.strftime('%Y'))
mth = int(set_Date.strftime('%m'))
dayz = int(set_Date.strftime('%d'))

goal_time = datetime.datetime(yr,mth,dayz,18,0,0,0)
ura = goal_time.replace(microsecond = 0)

def get_time():
    delta = ura - datetime.datetime.now()
    hr = delta.seconds // 3600
    mins = (delta.seconds % 3600) // 60
    secs = delta.seconds % 60    
    print('{} days, {:02d}:{:02d}:{:02d}'.format(delta.days, hr, mins, secs),end='\r')

while True:
    time.sleep(1)
    get_time()

0 个答案:

没有答案