From 2139014518befbf7c6f69b112d9d092f06eb63b6 Mon Sep 17 00:00:00 2001 From: GreenBlob Date: Tue, 22 Aug 2023 09:01:24 +0800 Subject: [PATCH] Update focus-timer.py --- focus-timer.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/focus-timer.py b/focus-timer.py index 35d006f..77bb86d 100644 --- a/focus-timer.py +++ b/focus-timer.py @@ -16,22 +16,27 @@ def break_window(breaktime): label = tk.Label(breakwindow, text = "It's time to take a break!", font = ("Times New Roman", 36), bg = '#FFFBE4') label.place(relx = 0.5, rely = 0.5, anchor = "center") - breakwindow.after(breaktime, breakwindow.destroy) + breakwindow.after(breaktime, lambda: on_close(breakwindow)) + +def on_close(window): + window.destroy() + on_ok(focusentry, breakentry, breaktime) def on_ok(focusentry, breakentry, breaktime): focustime = (focusentry.get()) breaktime = (breakentry.get()) breaktime = int(breaktime) - breaktime = breaktime * 1000 + breaktime = breaktime * 60000 focus_countdown(focustime, breaktime) def focus_countdown(count, breaktime): count = int(count) + print(count) if count > 0: count_label.config(text=str(count)) - inputwindow.after(1000, focus_countdown, count - 1, breaktime) + inputwindow.after(60000, focus_countdown, count - 1, breaktime) else: break_window(breaktime)