I have this calendar and I want to get the background color for selected cell how I can do that?
Current_Date = str(datetime.today())
Current_Date=Current_Date[0:10].split('-')
cal = Calendar(root, selectmode="day", year=int(Current_Date[0]),
month=int(Current_Date[1]), day=int(Current_Date[2]))
cal.pack(pady=20)
Frankly I don't know why you need to access cells and why you need to know cell's background. If you want to change color in cells then you should rather use tags`
BTW: you don't have to convert date to string and split it
tkcalendar
doesn't give direct access to cells. But there is hiddencal._calendar
which keeps all Labels used to create cells - and this way you could try to access label which you need. But Label doesn't use directlybackground
butstyle
and you would have to convert style to bacground color.This code display styles for all cells in current month
Result:
If you want to access when you click cell then you may have to create own class and overwrite method
_on_click
Result (when click some dates in calendar):