-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·66 lines (58 loc) · 2.4 KB
/
main.py
File metadata and controls
executable file
·66 lines (58 loc) · 2.4 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
60
61
62
63
64
65
66
"""
Main File for nhh (Next Half Hour)
"""
import PySimpleGUI as sg
from datetime import datetime, timedelta
def cnhh(now):
h, m = now.hour, now.minute
nhh = now
nhh = nhh + timedelta(minutes=25)
nhh = nhh.replace(second=0, microsecond=0)
if (nhh.minute < 30):
nhh = nhh.replace(minute = 30)
else:
nhh = nhh + timedelta(minutes=30)
nhh = nhh.replace(minute=0)
return nhh
layout = [
[sg.Text('Next Half Hour', size=(20, 2), justification='left')],
[sg.Text('', size=(10,2), font=('Helvetica', 20), justification='center', key='__CURTIME__'), sg.Text('next:', size=(10,2), justification='left'), sg.Text('', size=(10, 2), font=('Helvetica', 20), justification='center', key='__OUTPUT__')],
[sg.Text('',size=(10,2), justification='right', key='startTime'), sg.ProgressBar(1000, orientation='h', key='progbar'), sg.Text('', size=(10,2), justification='left', key='endTime')],
[sg.T(' ' * 5), sg.Button('Start', focus=True), sg.Cancel(),sg.Quit()]
]
window = sg.Window('Next Half Hour', layout)
monotasking, i = False, 0
diffTime = timedelta(seconds=0)
elapsedTime = timedelta(seconds=0)
startTime = datetime.now()
now = datetime.now()
nhh = cnhh(now)
timeT = now + timedelta(seconds=2)
while True:
event, values = window.Read(timeout=1000)
if event is None or event == 'Quit':
break
if event == 'Cancel':
monotasking = False
window.Element('progbar').UpdateBar(0)
now = datetime.now()
if event == 'Start':
if not monotasking:
monotasking = True
window.Element('__CURTIME__').Update('FOCUS!')
startTime = now
diffTime = nhh - now
if monotasking:
if now > nhh:
monotasking = False
window.BringToFront()
sg.Popup('Monotasking Section Complete!')
elapsedTime = now - startTime
window.Element('progbar').UpdateBar(1000 * elapsedTime/diffTime)
else:
window.Element('__CURTIME__').Update('{:02d}:{:02d}'.format(now.hour, now.minute))
nhh = cnhh(now)
startTime = now
window.Element('__OUTPUT__').Update('{:02d}:{:02d}'.format(nhh.hour, nhh.minute))
window.Element('startTime').Update('{:02d}:{:02d}'.format(startTime.hour, startTime.minute))
window.Element('endTime').Update('{:02d}:{:02d}'.format(nhh.hour, nhh.minute))