'int' object is not callable in tkcalendar

27 Views Asked by At

I am trying to create a calendar function that will change the background of a cell to a different colour to show that there is an event on that day. I am using tkinter and tkcalendar.

code

    testPage=Toplevel()
    testPage.title("New Booking")
    testPage.geometry("1366x768")
    canvas=Canvas(testPage, width=1366, height=768)
    canvas.pack()
    frame=Frame(testPage)
    topbar=canvas.create_rectangle(0,0, 1366,30, fill="gray")
        

    lblDate=canvas.create_text(400,300, text="")
    date=canvas.create_text(50, 100, text="Date: ", font=("Helvetica", 14))
    date_today=datetime.now()
    cal=Calendar(testPage, width=12, background='saddle brown', foreground='white', mindate=date_today, disabledforeground='red')
    cal.place(x=150, y=100)
    day=date(2024, 3, 15)
    cal.calevent_create(day, "", tags="test")
    cal.tag_config("test", background="red")

The error that I am receiving is with the line day=date(2024, 3, 15) and the error it is giving me is TypeError: 'int' object is not callable. I have tried using quotation marks around the dates ("2024", "3", "15") and I have also tried putting hyphens between the dates (2024-3-15)

Is there something else I am missing that I can try? Really appreciate any advice you can give. Thank you!

1

There are 1 best solutions below

0
j.jam On

Fixed

The line day=date(2024, 3, 15) needed to be day=datetime(2024, 3, 15).

Thank you!