'What is this "invalid command name while executing error" in tkinter, why does it happen, how do I fix it in my code?

I am a student who is learning python. I am currently making an alarm in tkinter GUI. When I run my code I see this error: ""invalid command name "2268780354496_check_events" while executing "2268780354496_check_events" ("after" script)""

My code:

from tkinter import *
import tkinter
import time
import winsound

clock = time.ctime(time.time())
clock = clock.split()[3]
hour = int(list(clock)[0] + list(clock)[1])
mint = int(list(clock)[3] + list(clock)[4])
sec = int(list(clock)[6] + list(clock)[7])

root = Tk()

root.title("Alarm")
root.iconbitmap(r"E:\Python\Nishu Code\Clock GUI\Clock.ico")
root.configure(background="#2c2c2c")
root.geometry("300x280")
root.resizable(False, False)

hour_label = Label(root, text = hour, bg = "#2c2c2c", fg = "White", font = ("Times", 15, "bold"))
hour_label.place(relx = 0.2, rely = 0.5, anchor = CENTER)

mint_label = Label(root, text = mint, bg = "#2c2c2c", fg = "White", font = ("Times", 15, "bold"))
mint_label.place(relx = 0.5, rely = 0.5, anchor = CENTER)

sec_label = Label(root, text = sec, bg = "#2c2c2c", fg = "White", font = ("Times", 15, "bold"))
sec_label.place(relx = 0.8, rely = 0.5, anchor = CENTER)

def increment1():
    global hour
    if hour != 23:hour+=1
    else:hour=0
    hour_label.config(text=hour)
    return hour
    
def decrement1():
    global hour
    if hour != 0:hour-=1
    else:hour=23
    hour_label.config(text=hour)
    return hour
    
def increment2():
    global mint
    if mint != 59:mint+=1
    else:mint=0
    mint_label.config(text=mint)
    return mint
    
def decrement2():
    global mint
    if mint != 0:mint-=1
    else:mint=59
    mint_label.config(text=mint)
    return mint
    
def increment3():
    global sec
    if sec != 59:sec+=1
    else:sec=0
    sec_label.config(text=sec)
    return sec
    
def decrement3():
    global sec
    if sec != 0:sec-=1
    else:sec=59
    sec_label.config(text=sec)
    return sec

def Set():
    h = hour_label.cget("text")
    m = mint_label.cget("text")
    s = sec_label.cget("text")
    h=int(h);m=int(h);s=int(s)
    if h<10:h = "0" + str(h)
    if m<10:m = "0" + str(m) 
    if s<10:s = "0" + str(s)
    alarm_time = str(h)+":"+str(m)+":"+str(s)
    while True:
        current_time = time.ctime(time.time())
        current_time = current_time.split()[3]
        time.sleep(1)
        if alarm_time == current_time:
            winsound.PlaySound("Alarm01.wav",winsound.SND_ASYNC)


heading = Label(root, text="Alarm", bg="#2c2c2c", fg="white", font = ("",20,""))
heading.place(relx = 0.5, rely = 0.1, anchor = CENTER)

heading = Label(root, text="Set Time", bg="#2c2c2c", fg="white", font = ("",15,""))
heading.place(relx = 0.5, rely = 0.23, anchor = CENTER)

h_up_button = Button(root, text="🔺", bg = "#2c2c2c", fg="White", borderwidth = 0, command = increment1)
h_down_button = Button(root, text="🔻", bg = "#2c2c2c", fg="White", borderwidth = 0, command = decrement1)

h_up_button.place(relx = 0.2, rely = 0.35, anchor = CENTER)
h_down_button.place(relx = 0.2, rely = 0.65, anchor = CENTER)

m_up_button = Button(root, text="🔺", bg = "#2c2c2c", fg="White", borderwidth = 0, command = increment2)
m_down_button = Button(root, text="🔻", bg = "#2c2c2c", fg="White", borderwidth = 0, command = decrement2)

m_up_button.place(relx = 0.5, rely = 0.35, anchor = CENTER)
m_down_button.place(relx = 0.5, rely = 0.65, anchor = CENTER)

s_up_button = Button(root, text="🔺", bg = "#2c2c2c", fg="White", borderwidth = 0, command = increment3)
s_down_button = Button(root, text="🔻", bg = "#2c2c2c", fg="White", borderwidth = 0, command = decrement3)

s_up_button.place(relx = 0.8, rely = 0.35, anchor = CENTER)
s_down_button.place(relx = 0.8, rely = 0.65, anchor = CENTER)

Set_alarm_button = Button(root, text = "SET ALARM", bg = "Black", fg = "White", font = ("",15,""), borderwidth = 0, command = Set)
Set_alarm_button.place(rely = 0.85, relx = 0.5, anchor = CENTER)

mainloop()

and this is the error

invalid command name "2268780354496_check_events"
    while executing
"2268780354496_check_events"
    ("after" script)
invalid command name "2268781513088_check_events"
    while executing
"2268781513088_check_events"
    ("after" script)
invalid command name "2268782309120_check_events"
    while executing
"2268782309120_check_events"
    ("after" script)
invalid command name "2268782308416_check_events"
    while executing
"2268782308416_check_events"
    ("after" script)
invalid command name "2268782257088_check_events"
    while executing
"2268782257088_check_events"
    ("after" script)
invalid command name "2268713725248_check_events"
    while executing
"2268713725248_check_events"
    ("after" script)
invalid command name "2268713670400_check_events"
    while executing
"2268713670400_check_events"
    ("after" script)
invalid command name "2268713598016_check_events"
    while executing
"2268713598016_check_events"
    ("after" script)
invalid command name "2268780748672_check_events"
    while executing
"2268780748672_check_events"
    ("after" script)
invalid command name "2268780215104_check_events"
    while executing
"2268780215104_check_events"
    ("after" script)
invalid command name "2268713610176_check_events"
    while executing
"2268713610176_check_events"
    ("after" script)

The error keeps coming as long as the code is running Any doubts about the code please tell me and PLEASE solve my problem. I am doing my coding in Spyder



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source