I created this GUI notifier, that I have to give it a task in the task_box and the needed time in the time_box, and it will countdown until 0 and will notify the task that I gave it at the beginning. However there's a bug that I can't seem to figure out (even after a lot of research), I can't set the time that I want, because the count is an argument in countdown function, it doesn't accept the value of the time_box.get() as an argument, I can only edit the code (like set the time in the countdown(count=10) function)
Code:
import time
from tkinter import *
from plyer import notification
from tkinter import messagebox
def space():
space = Label(text="", bg="darkgreen")
space.grid()
def countdown(count=10):
if task_box.get() != "" and time_box.get() != "" and time_box.get().isdigit():
# count = 60 * int(time_box.get())
count_label["text"] = count
if count > 0:
root.after(1000, countdown, count-1)
if count == 0:
set_notifier()
else:
messagebox.showwarning(title="Error", message="Please set task and / or time")
def set_notifier():
notification.notify(
title = f"{task_box.get()}",
message = "Don't be stupid, just do what I say!",
timeout=3
)
root = Tk()
# root.iconbitmap("yt.ico")
root.title("Notifier")
root.geometry("400x400")
root.columnconfigure(0, weight=1)
root.config(bg="darkgreen")
space()
space()
space()
task_label = Label(root, text="Enter task", bg="darkgreen", fg="white", font=("jost", 9, "bold"))
task_label.grid()
EntryVar = StringVar()
task_box = Entry(root, width=27, textvariable=EntryVar)
task_box.grid()
space()
time_label = Label(root, text="Set time (minutes)", bg="darkgreen", fg="white", font=("jost", 9, "bold"))
time_label.grid()
EntryVar = StringVar()
time_box = Entry(root, width=27, textvariable=EntryVar)
time_box.grid()
space()
space()
set_btn = Button(width=23, height=1, bg="darkgreen", fg="white", text="Set", font=("jost", 11, "bold"), command=countdown)
set_btn.grid()
space()
count_label = Label(root, text="", bg="darkgreen", fg="white")
count_label.grid()
space()
space()
root.bind('<Return>', set_notifier)
root.mainloop()
comman=then create new function withcountdown( int(time_box.get()) )and assign this function tocomman=, or usecommand=lambda:countdown( int(time_box.get()) )time_boxkeeps it as string and you have to convert to integerint(...)EntryVartotime_boxandtask_boxbut you never use it - you can remove it. If you want to use it then use different name forStringVarintime_boxand different name forStringVarintask_box