Skip to content

Commit 13fe96e

Browse files
committed
Small Update
Added the ability to only use eye care while timer is running
1 parent f82653d commit 13fe96e

4 files changed

Lines changed: 40 additions & 10 deletions

File tree

651 Bytes
Binary file not shown.

Version 1.0.0/Package/data_management.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import datetime
2-
32
from openpyxl.styles import Font
43
from .styles import *
54

@@ -96,6 +95,7 @@ def customize_excel(self) -> None:
9695
self.worksheet["E1"].value = "Subject:"
9796

9897
self.worksheet["Q1"].value = "Eye care:"
98+
self.worksheet["Q4"].value = "Only when timer running:"
9999

100100
self.worksheet["R1"].value = "Goals reached:"
101101
self.worksheet["R2"].value = self.goal_amount
@@ -238,7 +238,7 @@ def change_color(self) -> None:
238238
for widget in self.app.widget_list:
239239
widget.configure(fg_color=self.color, hover_color=self.highlight_color)
240240
self.app.progressbar.configure(progress_color = self.color)
241-
241+
self.app.eye_care_checkbox.configure(fg_color=self.color)
242242
self.app.create_graphs()
243243

244244
print("Color changed.")
@@ -260,8 +260,9 @@ def load_subject(self) -> None:
260260
return subject
261261

262262

263-
def save_eye_care(self, eye_care: str) -> None:
263+
def save_eye_care(self, eye_care: str, checkbox: str) -> None:
264264
self.worksheet["Q2"].value = eye_care
265+
self.worksheet["Q5"].value = checkbox
265266
print("Eye care saved.")
266267

267268

@@ -273,4 +274,11 @@ def load_eye_care(self) -> None:
273274

274275
self.app.eye_care_selection.configure(variable=ctk.StringVar(value=eye_care))
275276

277+
if self.worksheet["Q5"].value != None:
278+
checkbox = self.worksheet["Q5"].value
279+
else:
280+
checkbox = "Off"
281+
282+
self.app.eye_care_checkbox.configure(variable=ctk.StringVar(value=checkbox))
283+
276284
self.app.t1.start()

Version 1.0.0/main.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,16 @@ def _settings_gui_setup(self) -> None:
335335
height=button_height, command=lambda: self.data_manager.set_color(self.color_dropdown))
336336
self.color_button.place(anchor="s", relx=0.5, rely=0.9)
337337

338-
eye_care_frame = ctk.CTkFrame(self.settings_frame, fg_color=frame_color, height=200, width=int(frame_width/1.25), corner_radius=10)
338+
eye_care_frame = ctk.CTkFrame(self.settings_frame, fg_color=frame_color, height=250, width=int(frame_width/1.25), corner_radius=10)
339339
eye_care_frame.grid(column=1, row=0, padx=frame_padding, pady=frame_padding)
340340
eye_care_label = ctk.CTkLabel(eye_care_frame, text="Eye care", font=(font_family, font_size), text_color=font_color)
341341
eye_care_label.place(anchor="nw", relx=0.05, rely=0.05)
342342
self.eye_care_selection = ctk.CTkComboBox(eye_care_frame, values=["On", "Off"], state="readonly", width=100, height=30, dropdown_font=(font_family, int(font_size*0.75)),
343343
font=(font_family, int(font_size)), fg_color=border_frame_color, button_color=border_frame_color)
344-
self.eye_care_selection.place(anchor="center", relx=0.5, rely=0.45)
344+
self.eye_care_selection.place(anchor="center", relx=0.5, rely=0.35)
345+
self.eye_care_checkbox = ctk.CTkCheckBox(eye_care_frame, text="Only on when timer running", fg_color=button_color, hover=False, offvalue="Off",
346+
font=(font_family, font_size*0.8), text_color="white", checkmark_color=button_font_color, onvalue="On")
347+
self.eye_care_checkbox.place(anchor="center", relx=0.5, rely=0.55)
345348
eye_care_button = ctk.CTkButton(eye_care_frame, text="Save", font=(font_family, font_size), text_color=button_font_color, fg_color=button_color,
346349
hover_color=button_highlight_color, height=button_height, command=self.select_eye_care)
347350
eye_care_button.place(anchor="s", relx=0.5, rely=0.9)
@@ -542,7 +545,10 @@ def select_eye_care(self):
542545
eye_care = self.eye_care_selection.get()
543546
self.eye_care_selection.configure(variable=ctk.StringVar(value=eye_care))
544547

545-
self.data_manager.save_eye_care(eye_care)
548+
checkbox = self.eye_care_checkbox.get()
549+
self.eye_care_checkbox.configure(variable=ctk.StringVar(value=checkbox))
550+
551+
self.data_manager.save_eye_care(eye_care, checkbox)
546552

547553

548554
def reach_goal(self, timer_time: int) -> None:
@@ -597,12 +603,22 @@ def save_data(self) -> None:
597603

598604

599605
def eye_protection(self):
606+
checkbox = self.eye_care_checkbox.get()
600607
time_between = 60 * 20
601608
if self.eye_care_selection.get() == "On":
602-
time.sleep(time_between)
603-
if self.eye_care_selection.get() == "On":
604-
self.send_notification("Eye Protection", "Look away 20ft for 20 seconds")
605-
self.eye_protection()
609+
if checkbox == "On" and self.timer_manager.timer_running:
610+
time.sleep(time_between)
611+
if checkbox == "On" and self.timer_manager.timer_running:
612+
self.send_notification("Eye Protection", "Look away 20ft for 20 seconds")
613+
self.eye_protection()
614+
else:
615+
time.sleep(time_between)
616+
if self.eye_care_selection.get() == "On" and checkbox == "Off":
617+
self.send_notification("Eye Protection", "Look away 20ft for 20 seconds")
618+
self.eye_protection()
619+
else:
620+
time.sleep(10)
621+
self.eye_protection()
606622

607623

608624
def load_history(self):

requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
customtkinter==5.2.2
2+
DateTime==5.4
3+
matplotlib==3.8.2
4+
openpyxl==3.1.2
5+
pandas==2.1.4
6+
winotify==1.1.0

0 commit comments

Comments
 (0)