tkcalendar takes a lot of time to load when I try to add more than 10 calendar widgets

466 Views Asked by At

Hi I have a code where I have a button which adds calender widgets, when I add more than 10 or 11 widgets, the program lags a lot. It takes a lot of time to insert the widget, could someone please help me how to circumvent this issue ?

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)
1

There are 1 best solutions below

8
On

When I add root.mainloop() to the end of your example the code runs fine.

Make sure you have the mainloop in your code before you compile as it is required.