from tkinter import *
from tkcalendar import *
def get_date():
calendar.configure(today.get_date())
win = Tk()
win.title('Calendar Picker')
labeltext = StringVar()
label = Label(win,textvariable=labeltext)
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)
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
from tkcalendar import Calendar
File "C:\Python38\lib\site-packages\tkcalendar\__init__.py", line 26, in <module>
from tkcalendar.dateentry import DateEntry
File "C:\Python38\lib\site-packages\tkcalendar\dateentry.py", line 35, in <module>
from tkcalendar.calendar_ import Calendar
File "C:\Python38\lib\site-packages\tkcalendar\calendar_.py", line 27, in <module>
import calendar
File "E:/Python/Python Projects Fun\calendar.py", line 18, in <module>
today = Calendar(win,selectmode='day',year=2020,month=8,day=6)
NameError: name 'Calendar' is not defined
我已经 pip 安装了 tkcalendar,但是如果我使用日历小部件,它会显示 NameError。请问如果我将日历用于 tkcalendar 模块有什么要求?有没有我还没有安装的东西?有人知道如何解决上述问题吗?因为我检查了模块 tkcalendar 包括日历小部件。在我认出这个名字后,这个问题就崩溃了,在我理解错误并改变它之后,下次我会知道如何处理它。