问题描述
限时送ChatGPT账号..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模块使用Calendar有什么要求?有什么我还没有安装的吗?有谁知道如何解决上述问题?因为我检查了模块 tkcalendar 包括日历小部件.等我认了名字就崩溃了这个问题,等我明白了这个错误,改了以后,下次就知道怎么处理了.
I already pip installed tkcalendar however if I use the Calendar widget it showed the NameError. May I ask what's the requirement if I use Calendar for tkcalendar module? Is there something that I not yet installed? Anyone know how to solve the above problem? Because I checked the module tkcalendar includes Calendar widget. After I recognize the name crashes this problem, after I understand the mistake and change it then next time I will know how to deal with it.
推荐答案
你的脚本被命名为 calendar.py
这会导致使用的 Python 内置模块 calendar
崩溃通过 tkcalendar
.
Your script is named calendar.py
which crashes the Python built-in module calendar
which is used by tkcalendar
.
将您的脚本重命名为其他名称.
Rename your script to other name.
这篇关于我无法在 tkinter 中加载日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论