Change background for cell in Calendar using Python Tkinter?

682 Views Asked by At

I want to change the background for a particular cell in this calendar

cal = Calendar(root,selectmode="day",year=2020,month=7,day=10)

in Tkinter. but I do not know how to do that please help me.

1

There are 1 best solutions below

0
On BEST ANSWER

You can attach a tag to the particular day using calevent_create() and then use tag_config() to change the background color using the tag:

Below is an example:

import datetime

...

day = datetime.date(2020, 7, 20)
cal.calevent_create(day, "", tags="hi")
cal.tag_config("hi", background="red")