-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguiMode.py
More file actions
59 lines (47 loc) · 1.87 KB
/
guiMode.py
File metadata and controls
59 lines (47 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import sys
import os
from time import sleep
from datetime import datetime, timedelta
from PyQt5 import QtWidgets
from PyQt5 import uic
from PyQt5 import QtCore
from utils import resourcePath
class SetRemainingTimeThreadClass(QtCore.QThread):
def __init__(self, lcd, start_time_str):
super(SetRemainingTimeThreadClass,self).__init__()
self.lcdCountdown = lcd
self.start_time_str = start_time_str
def run(self):
start_time = datetime.strptime(self.start_time_str, '%d/%m/%Y %H:%M:%S')
remain_time = self.calculateRemaningTime(start_time,1)
while True:
new_value = str(remain_time).split(".")[0]
self.lcdCountdown.display(new_value)
sleep(1)
remain_time = remain_time-timedelta(seconds=1)
def calculateRemaningTime(self, start_time, doubling_time):
now = datetime.now()
end = start_time + timedelta(days=doubling_time)
remain = end - now
return remain
class InfoGUI(QtWidgets.QMainWindow):
def __init__(self, uipath, start_time_str):
super(InfoGUI, self).__init__()
uic.loadUi(uipath, self)
# QLCDNumber
self.lcdCountdown = self.findChild(QtWidgets.QLCDNumber, 'lcdNumber') # Find the button
self.threadclass = SetRemainingTimeThreadClass(self.lcdCountdown, start_time_str)
self.threadclass.start()
self.show()
def readInfectionDate(path):
with open(path,"r") as datefile:
for _ in range(2):
datefile.readline()
start_time_str = " ".join(datefile.readline().strip().split()[-2:])
return start_time_str
def displayInfoGUI(aeskeyfile):
start_time_str = readInfectionDate(aeskeyfile)
aptalgui_path = resourcePath("aptal.ui")
app = QtWidgets.QApplication(sys.argv)
window = InfoGUI(aptalgui_path, start_time_str)
sys.exit(app.exec_())