Skip to content
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.

Commit

Permalink
Update focus-timer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
a-blob committed Aug 21, 2023
1 parent e6767d1 commit 194343b
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions focus-timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

focustime = 0
breaktime = 0
count = 0


def break_window(breaktime):
breakwindow = tk.Tk()
Expand All @@ -17,27 +19,38 @@ def break_window(breaktime):
breakwindow.after(breaktime, breakwindow.destroy)


def on_ok():
def on_ok(focusentry, breakentry, breaktime):
focustime = (focusentry.get())
breaktime = (breakentry.get())
break_window(breaktime)
input_window.destroy()

breaktime = int(breaktime)
breaktime = breaktime * 1000
focus_countdown(focustime, breaktime)


def focus_countdown(count, breaktime):
count = int(count)
if count > 0:
count_label.config(text=str(count))
inputwindow.after(1000, focus_countdown, count - 1, breaktime)
else:
break_window(breaktime)

input_window = tk.Tk()
inputwindow = tk.Tk()

focus_label = tk.Label(input_window, text = "Focus time:")
focus_label = tk.Label(inputwindow, text = "Focus time:")
focus_label.pack()
focusentry = tk.Entry(input_window)
focusentry = tk.Entry(inputwindow)
focusentry.pack()

break_label = tk.Label(input_window, text = "Break time:")
break_label = tk.Label(inputwindow, text = "Break time:")
break_label.pack()
breakentry = tk.Entry(input_window)
breakentry = tk.Entry(inputwindow)
breakentry.pack()

ok_button = tk.Button(input_window, text = "Okay", command = on_ok)
ok_button = tk.Button(inputwindow, text = "Okay", command = lambda: on_ok(focusentry, breakentry, breaktime))
ok_button.pack()

input_window.mainloop()
count_label = tk.Label(inputwindow, text = "")
count_label.pack()

inputwindow.mainloop()

0 comments on commit 194343b

Please sign in to comment.