-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimer.py
52 lines (45 loc) · 1.26 KB
/
timer.py
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
#!/usr/bin/env python3
import eel
import sys
import typing
arg = sys.argv
if len(arg) >= 3:
HOUR = arg[1]
MINUTE = arg[2]
SECOND = arg[3]
else:
HOUR = 0
MINUTE = 0
SECOND = 0
@eel.expose
def timer(hour: typing.Any, minute: typing.Any, second: typing.Any) -> None:
eel.update_time(f"{hour}:{minute}:{second}")
if type(hour) != int:
hour = int(hour)
if type(minute) != int:
minute = int(minute)
if type(second) != int:
second = int(second)
while hour >= 0 and minute >= 0 and second >= 0:
eel.sleep(1)
if eel.reset_status()():
break
if eel.timer_status()() == "started":
second -= 1
if second < 0:
minute -= 1
second = 59
if minute < 0:
hour -= 1
minute = 59
if hour < 0:
hour = 0
minute = 0
second = 0
eel.play_time_up_sound()
break
eel.update_time(f"{hour}:{minute}:{second}")
return
if __name__ == "__main__":
eel.init("resource")
eel.start(f"/html/timer.html?h={HOUR}&m={MINUTE}&s={SECOND}", port=0)