from tkinter import *
from time import strftime
import winsound
clock = Tk()
clock.title("WhatAClock")
clock.geometry("300x400")
notebook = ttk.Notebook()
tab1_timedate = Frame(notebook)
tab2_alarm = Frame(notebook)
tab3_timer = Frame(notebook)
notebook.add(tab1_timedate, text="Time and Date")
notebook.add(tab2_alarm, text="Alarm")
notebook.add(tab3_timer, text="Timer")
notebook.pack(expand=TRUE, fill="both")
def realtime():
time_str = strftime("%H:%M:%S")
l1_time_timedate.config(text= time_str)
l1_time_alarm.config(text= time_str)
clock.after(1000, realtime)
def alarm(alarm_set):
time_str_alarm = strftime("%H:%M:%S")
if time_str_alarm == alarm_set:
winsound.PlaySound("sound.wav",winsound.SND_ASYNC)
else:
clock.after(1000, alarm_set)
def set_alarm():
"???alarm_set = f""{user_h.get():02}:{user_m.get():02}:{user_s.get():02}""???"
alarm_set = f"{user_h.get()}:{user_m.get()}:{user_s.get()}"
alarm(alarm_set)
l1_time_timedate = Label(tab1_timedate)
l1_time_alarm = Label(tab2_alarm)
l1_time_timedate.place(x=20, y=30)
l1_time_alarm.place(x=20, y=30)
user_h = StringVar()
user_m = StringVar()
user_s = StringVar()
entry_h = Entry(tab2_alarm, textvariable= user_h)
entry_m = Entry(tab2_alarm, textvariable= user_m)
entry_s = Entry(tab2_alarm, textvariable= user_s)
entry_h.place(x=100, y=30)
entry_m.place(x=130, y=30)
entry_s.place(x=160, y=30)
button_alarm = Button(tab2_alarm, command= set_alarm, text= "SET ALARM")
button_alarm.place(x=100, y=70)
realtime()
clock.mainloop()
"so apparently the padding with a 0 is the problem. the question marked line was given as a solution i believe but i still can t set the alarm and the tkinter callback exeption happens. Not even sure the 2 are related even xD Any clue?