I'm working on an assignements thats a reminder app using Python's Tkinter and win10toast for desktop notifications. I'm encountering an issue where the Tkinter interface becomes unresponsive after I press the button to activate the alarm function. The program does successfully display the toast notification when the specified time is reached, but the GUI freezes and does not respond to any input. Below is the relevant part of my code:
from tkinter import *
from win10toast import ToastNotifier
import time
import datetime
gluggi = Tk()
gluggi.geometry("400x200")
def toaststart():
notifier= ToastNotifier()
notifier.show_toast("skilaboð frá tölvu...", "ÁMINNING")
def alarm():
while True:
set_alarm_time = f"{hour.get()}:{minut.get()}:{sekund.get()}"
time.sleep(1)
current_time = datetime.datetime.now().strftime("%H:%M:%S")
if current_time == set_alarm_time:
toaststart()
Label(gluggi, text="áminning", font=("Helvetica 20 bold"), fg="red").pack(pady=10)
Label(gluggi, text="velja tíma", font=("Helvetica 15 bold")).pack()
rammi= Frame(gluggi)
rammi.pack()
hour=StringVar(gluggi)
hours =[f"{i:02}" for i in range(24)]
hour.set(hours[0])
hrs = OptionMenu(rammi, hour, *hours)
hrs.pack(side=LEFT)
minut=StringVar(gluggi)
mins =[f"{i:02}" for i in range(60)]
minut.set(mins[0])
min = OptionMenu(rammi, minut, *mins)
min.pack(side=LEFT)
sekund=StringVar(gluggi)
seks =[f"{i:02}" for i in range(60)]
sekund.set(seks[0])
sek = OptionMenu(rammi, sekund, *seks)
sek.pack(side=LEFT)
Button(gluggi, text="virkja áminningu", font=("Helvetica 15"), command=alarm).pack(pady=20)
gluggi.mainloop()
i get this error: WNDPROC return value cannot be converted to LRESULT
TypeError: WPARAM is simple, so must be an int object (got NoneType)
The GUI freezes right after I press the "virkja áminningu" button. How can I prevent the GUI from freezing while still using the alarm() function as intended?