-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.py
More file actions
199 lines (177 loc) · 6.42 KB
/
clock.py
File metadata and controls
199 lines (177 loc) · 6.42 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import time
import os
import sys
from sys import platform
import winsound
from datetime import datetime
import re
x = 0
dateParam = '%H %M %S'
ticks = 0
timerLength = 5
block = [
['████', '█ █', '█ █', '█ █', '████'], #0
[' ██ ', ' █ ', ' █ ', ' █ ', ' ███'], #1
['████', ' █', '████', '█ ', '████'], #2
['████', ' █', '████', ' █', '████'], #3
['█ █', '█ █', '████', ' █', ' █'], #4
['████', '█ ', '████', ' █', '████'], #5
['████', '█ ', '████', '█ █', '████'], #6
['████', ' █', ' █', ' █', ' █'], #7
['████', '█ █', '████', '█ █', '████'], #8
['████', '█ █', '████', ' █', '████'] #9
]
line = [
['┏━━┓', '┃ ┃', '┃ ┃', '┃ ┃', '┗━━┛'],
[' ━┓ ', ' ┃ ', ' ┃ ', ' ┃ ', ' ━┻━'],
['┏━━┓', ' ┃', '┏━━┛', '┃ ', '┗━━━'],
['━━━┓', ' ┃', '━━━┫', ' ┃', '━━━┛'],
['╻ ╻', '┃ ┃', '┗━━┫', ' ┃', ' ╹'],
['┏━━━', '┃ ', '┗━━┓', ' ┃', '━━━┛'],
['┏━━┓', '┃ ', '┣━━┓', '┃ ┃', '┗━━┛'],
['━━━┓', ' ┃', ' ┃', ' ┃', ' ╹'],
['┏━━┓', '┃ ┃', '┣━━┫', '┃ ┃', '┗━━┛'],
['┏━━┓', '┃ ┃', '┗━━┫', ' ┃', '┗━━┛']
]
double = [
['╔══╗', '║ ║', '║ ║', '║ ║', '╚══╝'],
[' ═╗ ', ' ║ ', ' ║ ', ' ║ ', ' ═╩═'],
['╔══╗', ' ║', '╔══╝', '║ ', '╚═══'],
['═══╗', ' ║', '═══╣', ' ║', '═══╝'],
['║ ║', '║ ║', '╚══╣', ' ║', ' ║'],
['╔═══', '║ ', '╚══╗', ' ║', '═══╝'],
['╔══╗', '║ ', '╠══╗', '║ ║', '╚══╝'],
['═══╗', ' ║', ' ║', ' ║', ' ║'],
['╔══╗', '║ ║', '╠══╣', '║ ║', '╚══╝'],
['╔══╗', '║ ║', '╚══╣', ' ║', '╚══╝']
]
colon = [
[' ', ' █ ', ' ', ' █ ', ' '],
[' ', ' ┃ ', ' ', ' ┃ ', ' '],
[' ', ' ║ ', ' ', ' ║ ', ' ']
]
font = block
clnFont = 0
def printTime():
theTime = datetime.now().strftime(dateParam)
def split(theTime):
return [char for char in theTime]
timeRn = split(theTime)
print(font[int(timeRn[0])][0] + ' ' + font[int(timeRn[1])][0] + ' ' + colon[clnFont][0] + ' ' + font[int(timeRn[3])][0] + ' ' + font[int(timeRn[4])][0] + ' ' + colon[clnFont][0] + ' ' + font[int(timeRn[6])][0] + ' ' + font[int(timeRn[7])][0])
print(font[int(timeRn[0])][1] + ' ' + font[int(timeRn[1])][1] + ' ' + colon[clnFont][1] + ' ' + font[int(timeRn[3])][1] + ' ' + font[int(timeRn[4])][1] + ' ' + colon[clnFont][1] + ' ' + font[int(timeRn[6])][1] + ' ' + font[int(timeRn[7])][1])
print(font[int(timeRn[0])][2] + ' ' + font[int(timeRn[1])][2] + ' ' + colon[clnFont][2] + ' ' + font[int(timeRn[3])][2] + ' ' + font[int(timeRn[4])][2] + ' ' + colon[clnFont][2] + ' ' + font[int(timeRn[6])][2] + ' ' + font[int(timeRn[7])][2])
print(font[int(timeRn[0])][3] + ' ' + font[int(timeRn[1])][3] + ' ' + colon[clnFont][3] + ' ' + font[int(timeRn[3])][3] + ' ' + font[int(timeRn[4])][3] + ' ' + colon[clnFont][3] + ' ' + font[int(timeRn[6])][3] + ' ' + font[int(timeRn[7])][3])
print(font[int(timeRn[0])][4] + ' ' + font[int(timeRn[1])][4] + ' ' + colon[clnFont][4] + ' ' + font[int(timeRn[3])][4] + ' ' + font[int(timeRn[4])][4] + ' ' + colon[clnFont][4] + ' ' + font[int(timeRn[6])][4] + ' ' + font[int(timeRn[7])][4])
def clear():
if platform == 'linux' or platform == 'linux2':
os.system('clear')
elif platform == 'darwin':
os.system('clear')
else:
os.system('cls')
def startMsg():
print('Commands:\n"clock" to start the clock,\n"timer" to start timer,\n"stopwatch" to start stopwatch,\n"alarm" to set an alarm,\n"fonts" to change clock font.\n[Pressing Ctrl + C brings you back to this menu.]')
def timer():
clear()
global ticks
timerHrs, timerMins, timerSecs = input('Input timer length separated by commas (hours, minutes, seconds): ').split(',')
timerLength = int(timerHrs) * 60 * 60 + int(timerMins) * 60 + int(timerSecs)
while ticks < int(timerLength):
try:
clear()
ticks += 1
print('Timer length: ' + str(timerLength) + 's')
print('------------------------')
print('Time passed: ' + str(ticks) + 's')
print('Time left: ' + str(int(timerLength) - int(ticks)) + 's')
time.sleep(1)
except KeyboardInterrupt:
clear()
system()
if int(ticks) == int(timerLength):
winsound.PlaySound('radarAlarm.wav', winsound.SND_FILENAME)
def alarm():
clear()
alarmTime = input('Input time when alarm should go off (hours:minutes): ')
clear()
print('Alarm will play at ' + alarmTime)
while True:
try:
if datetime.now().strftime('%H:%M') == alarmTime:
print('It is now: ' + alarmTime)
winsound.PlaySound('radarAlarm.wav', winsound.SND_FILENAME)
break
else:
pass
except KeyboardInterrupt:
clear()
system()
def stopwatch():
timePassed = 0
while x == 0:
try:
clear()
timePassed += 1
print('Time passed: ' + str(timePassed) + 's (CTRL + C to stop)')
time.sleep(1)
except KeyboardInterrupt:
clear()
print('Total time: ' + str(timePassed) + 's')
break
print('\nType "menu" to go back to menu.')
goMenu = input()
if goMenu == 'menu':
clear()
system()
def clock():
while x == 0:
try:
clear()
printTime()
time.sleep(1)
except KeyboardInterrupt:
clear()
system()
def fonts():
clear()
global font
global clnFont
print('1 - block █\n2 - line ┃\n3 - double ║')
inputOfFont = input()
if inputOfFont == '1':
font = block
clnFont = 0
clear()
system()
elif inputOfFont == '2':
font = line
clnFont = 1
clear()
system()
elif inputOfFont == '3':
font = double
clnFont = 2
clear()
system()
else:
print('Invalid Input.')
clear()
system()
def system():
os.system('mode con: cols=50 lines=8')
startMsg()
inputString = input()
if inputString == 'clock':
clock()
elif inputString == 'fonts':
fonts()
elif inputString == 'timer':
timer()
elif inputString == 'stopwatch':
stopwatch()
elif inputString == 'alarm':
alarm()
else:
print('Invalid Input.')
system()
system()