Skip to content

Commit 14720f8

Browse files
committed
Eye Care Functionality + UI Improvements + Bug Fixes
1 parent 7e52eca commit 14720f8

7 files changed

Lines changed: 318 additions & 119 deletions

File tree

0 Bytes
Binary file not shown.
Binary file not shown.
39 Bytes
Binary file not shown.

Version 1.0.0/Package/data_management.py

Lines changed: 85 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,25 @@ def __init__(self, App, timer_manager, workbook, worksheet):
1414
self.initialize_variables()
1515

1616

17-
def initialize_variables(self):
17+
def initialize_variables(self) -> None:
1818
self.day_name_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
1919
self.date_list = []
2020
self.duration_list = []
2121
self.total_duration = 0
2222
self.graph_color = "#f38064"
23-
self.widget_list = []
2423

2524

26-
def initialize_new_file_variables(self):
25+
def initialize_new_file_variables(self) -> None:
2726
self.goal_amount = 0
2827
self.data_amount = 0
2928
self.monday_duration = self.tuesday_duration = self.wednesday_duration = self.thursday_duration = self.friday_duration = self.saturday_duration = self.sunday_duration = 0
3029
self.color_name = "Orange"
30+
31+
self.customize_excel()
3132
self.save_color()
3233

3334

34-
def collect_data(self):
35+
def collect_data(self) -> None:
3536
self.data_amount = int(self.worksheet["Z2"].value)
3637
self.goal_amount = int(self.worksheet["R2"].value)
3738

@@ -40,7 +41,7 @@ def collect_data(self):
4041
print("Data collected.")
4142

4243

43-
def data_to_variable(self):
44+
def data_to_variable(self) -> None:
4445
self.clear_graph_lists()
4546

4647
for data in range(2, self.data_amount + 2):
@@ -53,9 +54,9 @@ def data_to_variable(self):
5354
self.total_duration = sum(self.duration_list)
5455

5556

56-
def save_data(self):
57+
def save_data(self) -> None:
5758
self.initialize_variables()
58-
self.save_weekday()
59+
self.set_weekday()
5960
self.save_color()
6061

6162
self.data_amount += 1
@@ -74,60 +75,62 @@ def save_data(self):
7475
self.app.reset_timers()
7576

7677

77-
def write_to_excel(self):
78+
def write_to_excel(self) -> None:
7879
self.worksheet["A" + str((self.data_amount + 1))].value = self.start_time.strftime("%d/%m/%Y %H:%M")
7980
self.worksheet["B" + str((self.data_amount + 1))].value = self.stop_time.strftime("%d/%m/%Y %H:%M")
8081
self.worksheet["C" + str((self.data_amount + 1))].value = self.duration
8182
self.worksheet["D" + str((self.data_amount + 1))].value = self.timer_manager.break_time/60
83+
self.worksheet["E" + str((self.data_amount + 1))].value = self.app.subject_selection.get()
8284

8385
self.worksheet["R2"].value = self.goal_amount
8486

8587
self.worksheet["Z2"].value = self.data_amount
8688
self.workbook.save(self.app.data_file)
8789

8890

89-
def customize_excel(self):
91+
def customize_excel(self) -> None:
9092
self.worksheet["A1"].value = "Start:"
9193
self.worksheet["B1"].value = "End:"
9294
self.worksheet["C1"].value = "Duration:"
9395
self.worksheet["D1"].value = "Break:"
96+
self.worksheet["E1"].value = "Subject:"
97+
98+
self.worksheet["Q1"].value = "Eye care:"
9499

95100
self.worksheet["R1"].value = "Goals reached:"
96101
self.worksheet["R2"].value = self.goal_amount
97102

103+
self.worksheet["S1"].value = "Subject:"
104+
105+
self.worksheet["T1"].value = "Color:"
98106
self.worksheet["T2"].value = self.color_name
99107

100-
self.worksheet["W2"].value = self.monday_duration
101-
self.worksheet["W3"].value = self.tuesday_duration
102-
self.worksheet["W4"].value = self.wednesday_duration
103-
self.worksheet["W5"].value = self.thursday_duration
104-
self.worksheet["W6"].value = self.friday_duration
105-
self.worksheet["W7"].value = self.saturday_duration
106-
self.worksheet["W8"].value = self.sunday_duration
108+
self.worksheet["W1"].value = "Weekday duration:"
107109

108110
self.worksheet["Z1"].value = "Data amount: "
109111
self.worksheet["Z1"].font = Font(bold=True, size=14)
110112
self.worksheet["Z2"].value = self.data_amount
111113

114+
self.save_weekday_data()
112115
self.style_excel()
113116

114117
self.workbook.save(self.app.data_file)
115118
print("Excel customized.")
116119

117120

118-
def style_excel(self):
121+
def style_excel(self) -> None:
119122
self.worksheet["A1"].font = Font(bold=True, size=14)
120123
self.worksheet["B1"].font = Font(bold=True, size=14)
121124
self.worksheet["C1"].font = Font(bold=True, size=14)
122125
self.worksheet["D1"].font = Font(bold=True, size=14)
123126
self.worksheet["E1"].font = Font(bold=True, size=14)
124127

125128

126-
def get_start_time(self):
129+
def get_start_time(self) -> None:
127130
self.start_time = datetime.datetime.now()
128131

129132

130-
def calculate_duration(self):
133+
def calculate_duration(self) -> float:
131134
duration = self.timer_manager.timer_time - self.timer_manager.break_time
132135
if duration < 0:
133136
duration = 0
@@ -136,11 +139,11 @@ def calculate_duration(self):
136139
return duration
137140

138141

139-
def increase_goal_streak(self):
142+
def increase_goal_streak(self) -> None:
140143
self.goal_amount += 1
141144

142145

143-
def reset_data(self, workbook, worksheet):
146+
def reset_data(self, workbook, worksheet) -> None:
144147
self.workbook = workbook
145148
self.worksheet = worksheet
146149

@@ -152,12 +155,12 @@ def reset_data(self, workbook, worksheet):
152155
print("Data reset.")
153156

154157

155-
def clear_graph_lists(self):
158+
def clear_graph_lists(self) -> None:
156159
self.date_list.clear()
157160
self.duration_list.clear()
158161

159162

160-
def collect_day_data(self):
163+
def collect_day_data(self) -> None:
161164
self.monday_duration = int(self.worksheet["W2"].value)
162165
self.tuesday_duration = int(self.worksheet["W3"].value)
163166
self.wednesday_duration = int(self.worksheet["W4"].value)
@@ -169,68 +172,105 @@ def collect_day_data(self):
169172
self.day_duration_list = [self.monday_duration, self.tuesday_duration, self.wednesday_duration, self.thursday_duration, self.friday_duration, self.saturday_duration, self.sunday_duration]
170173

171174

172-
def save_weekday(self):
175+
def set_weekday(self) -> None:
173176
duration = self.calculate_duration()
174177
weekday_today = datetime.datetime.now().weekday()
175178

176179
match weekday_today:
177180
case 0:
178181
self.monday_duration += duration
179-
self.worksheet["W2"].value = self.monday_duration
180182
case 1:
181183
self.tuesday_duration += duration
182-
self.worksheet["W3"].value = self.tuesday_duration
183184
case 2:
184185
self.wednesday_duration += duration
185-
self.worksheet["W4"].value = self.wednesday_duration
186186
case 3:
187187
self.thursday_duration += duration
188-
self.worksheet["W5"].value = self.thursday_duration
189188
case 4:
190189
self.friday_duration += duration
191-
self.worksheet["W6"].value = self.friday_duration
192190
case 5:
193191
self.saturday_duration += duration
194-
self.worksheet["W7"].value = self.saturday_duration
195192
case 6:
196193
self.sunday_duration += duration
197-
self.worksheet["W8"].value = self.sunday_duration
194+
195+
self.save_weekday_data()
198196

199197
self.workbook.save(self.app.data_file)
200198
print("Weekday saved.")
201199

202200

203-
def set_color(self, color_dropdown):
201+
def save_weekday_data(self) -> None:
202+
self.worksheet["W2"].value = self.monday_duration
203+
self.worksheet["W3"].value = self.tuesday_duration
204+
self.worksheet["W4"].value = self.wednesday_duration
205+
self.worksheet["W5"].value = self.thursday_duration
206+
self.worksheet["W6"].value = self.friday_duration
207+
self.worksheet["W7"].value = self.saturday_duration
208+
self.worksheet["W8"].value = self.sunday_duration
209+
210+
211+
def set_color(self, color_dropdown) -> None:
204212
self.color_name = color_dropdown.get()
205213
print("Color set.")
206214
self.save_color()
207215

208216

209-
def save_color(self):
217+
def save_color(self) -> None:
210218
self.worksheet["T2"].value = self.color_name
211219
self.load_color()
212220

213221

214-
def load_color(self):
215-
color_name = self.worksheet["T2"].value
216-
self.app.color_dropdown.configure(variable=ctk.StringVar(value=color_name))
222+
def load_color(self) -> None:
223+
self.color_name = self.worksheet["T2"].value
224+
self.app.color_dropdown.configure(variable=ctk.StringVar(value=self.color_name))
217225
colors = {"Orange": [orange_button_color, orange_highlight_color, orange_pie_colors],
218226
"Green": [green_button_color, green_highlight_color, green_pie_colors],
219227
"Blue": [blue_button_color, blue_highlight_color, blue_pie_colors]}
220228

221-
self.color = colors[color_name][0]
222-
self.highlight_color = colors[color_name][1]
223-
self.pie_colors = colors[color_name][2]
229+
self.color = colors[self.color_name][0]
230+
self.highlight_color = colors[self.color_name][1]
231+
self.pie_colors = colors[self.color_name][2]
224232
self.graph_color = self.color
225233
print("Color loaded.")
226-
self.change_color(self.color, self.highlight_color)
234+
self.change_color()
227235

228236

229-
def change_color(self, color, highlight_color):
230-
for widget in self.widget_list:
231-
widget.configure(fg_color=color, hover_color=highlight_color)
232-
self.app.progressbar.configure(progress_color = color)
237+
def change_color(self) -> None:
238+
for widget in self.app.widget_list:
239+
widget.configure(fg_color=self.color, hover_color=self.highlight_color)
240+
self.app.progressbar.configure(progress_color = self.color)
233241

234242
self.app.create_graphs()
235243

236-
print("Color changed.")
244+
print("Color changed.")
245+
246+
247+
def save_subject(self, subject: str) -> None:
248+
self.worksheet["S2"].value = subject
249+
print("Subject saved.")
250+
251+
252+
def load_subject(self) -> None:
253+
if self.worksheet["S2"].value != None:
254+
subject = self.worksheet["S2"].value
255+
else:
256+
subject = "Other"
257+
258+
self.app.subject_selection.configure(variable=ctk.StringVar(value=subject))
259+
260+
return subject
261+
262+
263+
def save_eye_care(self, eye_care: str) -> None:
264+
self.worksheet["Q2"].value = eye_care
265+
print("Eye care saved.")
266+
267+
268+
def load_eye_care(self) -> None:
269+
if self.worksheet["Q2"].value != None:
270+
eye_care = self.worksheet["Q2"].value
271+
else:
272+
eye_care = "Off"
273+
274+
self.app.eye_care_selection.configure(variable=ctk.StringVar(value=eye_care))
275+
276+
self.app.t1.start()

Version 1.0.0/Package/eye_care.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import time
2+
3+
class EyeCare:
4+
def __init__(self, app):
5+
self.app = app
6+
def eye_protection(self):
7+
time_between = 1000 * 60 * 20
8+
if self.app.eye_care_selection.get() == "On":
9+
time.sleep(time_between)
10+
self.eye_protection()

Version 1.0.0/Package/styles.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
button_highlight_color = "#f5937a"
2424
button_font_color = "black"
2525

26-
tab_frame_color = "#1f1f1f"
26+
tab_frame_color = "#222222"
2727
tab_frame_width = 200
28-
tab_highlight_color = "#262626"
28+
tab_highlight_color = "#333333"
29+
tab_selected_color = "#343434"
2930
tab_color = tab_frame_color
3031
tab_font_weight = "normal"
3132
tab_font_family = "Calibri"

0 commit comments

Comments
 (0)