Skip to content

Commit 8c20a14

Browse files
authored
Merge pull request #2 from OOCAZ/dev/add-linux
added better cancel handling and fixed console errors
2 parents f5ba05b + 1166f38 commit 8c20a14

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/loctight.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

112114
def 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

119121
def 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

142144
def short():
@@ -210,7 +212,7 @@ def enable_buttons():
210212

211213
entry = tb.Entry(custom_frame, width=10)
212214
entry.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)
214216
button3.grid(row=0, column=1)
215217

216218
checks = tb.IntVar(value=0)

0 commit comments

Comments
 (0)