I have created a medicine reminder in tkinter.It works but as I click the button "Notify", my program freezes and says not responding but the program still works.
from tkinter import *
from plyer import notification
from datetime import datetime
import tkinter.messagebox as msg
root = Tk()
root.title("Medicine reminder")
def notify():
msg.showinfo("Reminder Set",f"You will be notified at {timeSlider.get()}. Make sure that you don't close the program")
while True:
hour = datetime.now().hour
if hour == timeSlider.get():
notification.notify(
title=f"Take your medicine {medicine.get()}",
message=f"You have scheduled it for {timeSlider.get()}",
# displaying time
timeout=15)
break
Label(text="Medicine Reminder", font="comicsans 20 bold").pack(anchor="w", padx=10, pady=10)
medicine = StringVar()
medicine_entry = Entry(font="comicsans 20", textvariable=medicine)
medicine_entry.insert(0, "Name of medicine")
medicine_entry.pack(anchor="w", padx=10, pady=5)
timeSlider = Scale(from_=0, to=24, orient=HORIZONTAL)
Label(text="Enter the time you want to get notified at:", font="comicsans 15").pack(anchor="w", padx=10)
timeSlider.pack(anchor="w", padx=10)
Button(text="Notify me", font="comicsans 15 bold", relief=SUNKEN, borderwidth=6, command=notify).pack(anchor="w",
pady=15, padx=10)
root.mainloop()
whileloop is causing the problem, try usingafter