@@ -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 ):
0 commit comments