-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
145 lines (135 loc) · 4.78 KB
/
main.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
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
from win10toast_click import ToastNotifier
import time
import os
import sys
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
def validate_int_input():
valid = False
while not(valid):
res = input("> ")
try:
res = int(res)
if (res > 0):
valid = True
except:
print("Please enter a whole number of minutes.")
return res
def show_notif(message : str):
toaster.show_toast(
"Pomodoro Timer", # title
message, # message
icon_path="pomodoro.ico", # 'icon_path'
duration=1, # for how many seconds toast should be visible; None = leave notification in Notification Center
threaded=True, # True = run other code in parallel; False = code execution will wait till notification disappears
)
num_cycles = 4
num_subcycles = 4
work_time = 25
short_break_time = 5
long_break_time = 15
editing_mode = True
os.system('cls' if os.name == 'nt' else 'clear')
while (editing_mode):
print(" ╔══════════════════════╗")
print(" ║ Pomodoro Timer ║")
print(" ╚══════════════════════╝")
print(color.UNDERLINE + " Current Settings " + color.END)
print(f" 1. Num of Subcycles: {num_subcycles}")
print(f" 2. Work Time: {work_time} m ")
print(f" 3. Short Break: {short_break_time} m ")
print(f" 4. Long Break: {long_break_time} m ")
print(f" 5. Num of Cycles: {num_cycles} ")
valid_res = False
while not(valid_res):
res = input("Enter corresponding number to edit, 6 to edit all sequentially, or 0 to start timer\n> ").strip()
if (res == "1"):
valid_res = True
print("Enter new subcycle length.")
num_subcycles = validate_int_input()
elif (res == "2"):
valid_res = True
print("Enter new work time in minutes.")
work_time = validate_int_input()
elif (res == "3"):
valid_res = True
print("Enter new short break time in minutes.")
short_break_time = validate_int_input()
elif (res == "4"):
valid_res = True
print("Enter new long break time in minutes.")
long_break_time = validate_int_input()
elif (res == "5"):
valid_res = True
print("Enter new number of cycles.")
num_cycles = validate_int_input()
elif (res == "6"):
valid_res = True
print("Enter new subcycle length.")
num_subcycles = validate_int_input()
print("Enter new work time in minutes.")
work_time = validate_int_input()
print("Enter new short break time in minutes.")
short_break_time = validate_int_input()
print("Enter new long break time in minutes.")
long_break_time = validate_int_input()
print("Enter new number of cycles.")
num_cycles = validate_int_input()
elif (res == "0"):
editing_mode = False
valid_res = True
else:
print("Please enter a valid number:")
os.system('cls' if os.name == 'nt' else 'clear')
toaster = ToastNotifier()
cycle_count = 0
subcycle_count = 0
total_subcycles = 0
time_left = work_time
mode = "true"
show_notif("It's now time to work!")
while (True):
print("(Program is Running)")
print(f"Current Cycle: {cycle_count + 1}")
print(f"Current Subcycle: {subcycle_count + 1}")
if (mode):
print(f"Work Time Left: {time_left}")
else:
print(f"Break Time Left: {time_left}")
print("=======================================")
time.sleep(60)
time_left -= 1
if time_left <= 0:
mode = not(mode)
if (mode):
subcycle_count += 1
if (cycle_count >= num_cycles):
break
if ((subcycle_count) / num_subcycles == 1):
print("Reseting cycle!")
subcycle_count = 0
cycle_count += 1
print("Work Time!")
show_notif("It's now time to work!")
time_left = work_time
else:
if ((subcycle_count + 1) == num_subcycles):
print("Long Break time!")
show_notif("Time to take a long break!")
time_left = long_break_time
else:
print("Short Break time!")
show_notif("Time to take a short break!")
time_left = short_break_time
show_notif("You've finished all of the cycles! Timer has closed.")
print("Finished!")
sys.exit(0)