from tkinter import *
from tkcalendar import Calendar
def get_date():
label.configure(text=str(today.get_displayed_month()))
today.configure(day=str(today.get_date()))
win = Tk()
win.title('Calendar Picker')
label = Label(win,text='August 2020')
label.pack(pady=10)
btn = Button(win,text='Pick a date',command=get_date)
btn.pack(pady=10)
today = Calendar(win,selectmode='day',year=2020,month=8,day=6)
today.pack(pady=10)
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python38\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "E:\Python\Python Projects Fun\calproject.py", line 6, in get_date
today.configure(day=str(today.get_date()))
File "C:\Python38\lib\site-packages\tkcalendar\calendar_.py", line 1612, in configure
self[item] = value
File "C:\Python38\lib\site-packages\tkcalendar\calendar_.py", line 518, in __setitem__
raise AttributeError("Calendar object has no attribute %s." % key)
AttributeError: Calendar object has no attribute day.
抱歉,当我按下“选择日期”按钮时,出现了上述错误。请问如果我想在移动月份时在窗口顶部显示相应的日期,我应该使用什么?因为我不清楚文档所以有人可以教我这个方法吗?解决上述错误的最佳方法是什么?