My python code has a ui calendar and button but i don't know how to get the label to print and after destroying the label before it
from tkinter import*
from tkcalendar import*
root=Tk()
root.title("Code project")
def selectDate():
myDate =my_Cal.get_date()
selectedDate = Label(text=myDate)
selectedDate.pack()
my_Cal= Calendar(root, setmode = 'day', date_pattern = 'd/m/yy')
my_Cal.pack()
openCal = Button(root, text="Select Date", command=selectDate)
openCal.pack()
root.mainloop()
you may need to zoom in a bit
You have to define your label just once and update just it's text like this:
from tkinter import*
from tkcalendar import*
root=Tk()
root.title("Code project")
selectedDate = Label(root, text="")
def selectDate():
myDate =my_Cal.get_date()
selectedDate.config(text=myDate)
selectedDate.pack()
my_Cal= Calendar(root, setmode = 'day', date_pattern = 'd/m/yy')
my_Cal.pack()
openCal = Button(root, text="Select Date", command=selectDate)
openCal.pack()
root.mainloop()