How do I create a date picker in tkinter?

TkinterServer Side ProgrammingProgramming

Tkcalendar is a Python package which provides DateEntry and Calendar widgets for tkinter applications. In this article, we will create a date picker with the help of DateEntry Widget.

A DateEntry widget contains three fields that refer to the general format of Date as MM/DD/YY. By creating an object of DateEntry widget, we can choose a specific Date in the application.


#Import tkinter library
from tkinter import *
from tkcalendar import Calendar, DateEntry
#Create an instance of tkinter frame
win= Tk()
#Set the Geometry
win.title("Date Picker")
#Create a Label
Label(win, text= "Choose a Date", background= 'gray61', foreground="white").pack(padx=20,pady=20)
#Create a Calendar using DateEntry
cal = DateEntry(win, width= 16, background= "magenta3", foreground= "white",bd=2)


Execute the above code snippet to display a date picker in the window.

Now pick any date from the DateEntry Widget to set and reflect the output.

Published on 15-Apr-2021 17:09:03