@@ -103,17 +103,19 @@ def countdown(variable, checks):
103103 # Check the IntVar at the end, not at the start! That way user can change mind
104104 if checks .get () == 0 :
105105 lock_workstation ()
106+
107+ # Reset state and GUI on the main thread to ensure it works even after computer lock
106108 timer_running [0 ] = False
107109 paused [0 ] = False
108- pause_button .config (text = "Pause Timer" , state = tb . DISABLED )
109- enable_buttons ( )
110+ window . after ( 0 , lambda : pause_button .config (text = "Pause Timer" , state = DISABLED ) )
111+ window . after ( 0 , enable_buttons )
110112
111113
112114def update_time_label (m , s ):
113115 # Only update if timer is running or resetting to 00:00
114116 if timer_running [0 ] or (m == 0 and s == 0 ):
115117 time_str = f"Time Left: { m :02} :{ s :02} "
116- label3 .config (text = time_str )
118+ window . after ( 0 , lambda : label3 .config (text = time_str ) )
117119
118120
119121def start_timer (duration ):
@@ -136,7 +138,7 @@ def cancel_timer():
136138 pause_button .config (text = "Pause Timer" , state = "disabled" )
137139 enable_buttons ()
138140 update_time_label (0 , 0 )
139- entry .delete (0 , tb . END ) # Clear the entry field when cancelling
141+ entry .delete (0 , END ) # Clear the entry field when cancelling
140142
141143
142144def short ():
@@ -210,7 +212,7 @@ def enable_buttons():
210212
211213entry = tb .Entry (custom_frame , width = 10 )
212214entry .grid (row = 0 , column = 0 , padx = (0 , 10 ))
213- button3 = tb .Button (custom_frame , text = "Custom (min)" , command = custom )
215+ button3 = tb .Button (custom_frame , text = "Custom Timer Start (min)" , command = custom )
214216button3 .grid (row = 0 , column = 1 )
215217
216218checks = tb .IntVar (value = 0 )
0 commit comments