当我尝试添加10个以上的日历小部件时,tkcalendar需要花费大量时间来加载



嗨,我有一个代码,其中有一个添加日历小部件的按钮,当我添加超过10或11个小部件时,程序会滞后很多。插入小部件需要很多时间,有人能帮我如何绕过这个问题吗?

from tkinter import Button, Tk
from tkcalendar import  DateEntry
root = Tk()
Date = []
def Add():
Date.append({})
n = len(Date)-1
Date[n]= DateEntry(root)
Date[n].grid(row=n+1, column=0)
print (n)
button = Button(root, text='Add', command=Add).grid(row=0, column=0)

当我将root.mainloop()添加到示例的末尾时,代码运行良好。

在根据需要进行编译之前,请确保代码中有主循环。

最新更新