diff --git a/src/ui/test/test.py b/src/ui/test/test.py index 8c1ea2f..b834aba 100755 --- a/src/ui/test/test.py +++ b/src/ui/test/test.py @@ -4,6 +4,8 @@ import os import sys import weakref from datetime import datetime, timedelta +from distutils.util import change_root + from PyQt5.QtCore import QTimer, pyqtSlot, pyqtSignal from PyQt5.QtWidgets import QMessageBox from lib.db import Archive, Recipes, Users @@ -221,15 +223,20 @@ class Test(Widget): self.next_timer.timeout.connect(self.next) self.next() - def refresh_time(self, init=False): - if init: + if init and not hasattr(self, 'time_timer'): self.time_timer = QTimer() self.time_timer.setSingleShot(True) self.time_timer.timeout.connect(self.refresh_time) + t = datetime.now() - self.time_l.setText("{d}/{mo}/{y}\n{h}:{m}".format(y=t.year, mo=t.month, d=t.day, h=t.hour, m=t.minute)) - self.time_timer.start(60 - t.second) + self.time_l.setText("{d}/{mo}/{y}\n{h}:{m:02d}".format( + y=t.year, mo=t.month, d=t.day, h=t.hour, m=t.minute + )) + + # Always restart the timer, ensuring intervals are set correctly + if hasattr(self, 'time_timer'): # Safeguard for uninitialized timer + self.time_timer.start((60 - t.second) * 1000) def select_step_img(self, step, suffix=None): img_path = "./src/ui/imgs"