dededdew
This commit is contained in:
27
test1.py
27
test1.py
@@ -1,26 +1,11 @@
|
||||
import time
|
||||
from tqdm import tqdm
|
||||
from datetime import datetime
|
||||
|
||||
pbar = tqdm(total=30)
|
||||
|
||||
# 获取当前时间的分钟数
|
||||
def get_current_minute():
|
||||
now = datetime.now()
|
||||
return now.minute
|
||||
for i in range(31): # 包含0~30
|
||||
pbar.n = i # 直接设置进度
|
||||
pbar.refresh() # 刷新显示
|
||||
time.sleep(0.2)
|
||||
|
||||
|
||||
# 计算进度
|
||||
def calculate_progress(minute):
|
||||
return minute % 30
|
||||
|
||||
|
||||
# 创建进度条
|
||||
with tqdm(total=30, desc="时间进度", unit="分钟") as pbar:
|
||||
while True:
|
||||
current_minute = get_current_minute()
|
||||
progress = calculate_progress(current_minute)
|
||||
# 重置进度条并更新到计算出的进度
|
||||
pbar.reset()
|
||||
pbar.update(progress)
|
||||
# 每秒更新一次进度条
|
||||
time.sleep(1)
|
||||
pbar.close()
|
||||
|
||||
@@ -169,11 +169,11 @@ class WeexTransaction:
|
||||
current_minute = current_time.tm_min
|
||||
|
||||
if current_minute < 30:
|
||||
self.pbar.reset()
|
||||
self.pbar.update(current_minute)
|
||||
self.pbar.n = current_minute
|
||||
self.pbar.refresh()
|
||||
else:
|
||||
self.pbar.reset()
|
||||
self.pbar.update(current_minute - 30)
|
||||
self.pbar.n = current_minute - 30
|
||||
self.pbar.refresh()
|
||||
|
||||
if current_minute in [0, 30]: # 判断是否是 新的30分钟了
|
||||
|
||||
@@ -211,7 +211,7 @@ class WeexTransaction:
|
||||
if self.direction:
|
||||
self.to_do_page()
|
||||
|
||||
self.pbar = tqdm(total=30) # 重置进度条
|
||||
self.pbar.reset() # 重置进度条
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user