Tkinter Designer

← tkinter how-to

How do I add a date picker to tkinter?

The standard library has no date widget, so this needs a package: tkcalendar provides DateEntry, a text field with a calendar that drops down when clicked.

# pip install tkcalendar
import tkinter as tk
from tkcalendar import DateEntry

root = tk.Tk()

picked = DateEntry(root, date_pattern="yyyy-mm-dd")
picked.pack(padx=10, pady=10)

def save():
    d = picked.get_date()        # a datetime.date
    print(d, d.year, d.month)

tk.Button(root, text="Save", command=save).pack()
root.mainloop()

get_date() and get() are not the same

get_date() returns a datetime.date, which is what you want for storing, comparing or doing arithmetic on. get() returns the text exactly as displayed, which follows date_pattern — so the same day reads as 2026-03-09 under one pattern and 09/03/2026 under another.

That makes the pattern a display concern only. Change it freely for your users without touching the code that reads the value, as long as that code uses get_date().

picked.get_date()     # datetime.date(2026, 3, 9)
picked.get()          # '2026-03-09' or '09/03/2026', per date_pattern

Setting the date from code

set_date() accepts a date object and moves both the field and the calendar, which is how you restore a saved value when a window opens.

import datetime
picked.set_date(datetime.date(2026, 3, 9))

Limiting the range

mindate and maxdate grey out everything outside the window you allow, which is a better guard than validating after the fact — a booking form that cannot offer yesterday never has to reject it.

DateEntry(root, mindate=datetime.date.today())

If you are already using ttkbootstrap

ttkbootstrap ships its own date entry that matches the active theme, so a project already using it does not need tkcalendar as well. On plain tkinter and CustomTkinter, tkcalendar is the one to install.

Doing it without the lookup

Drag a Date picker on and the export adds the right import for the toolkit you have chosen, along with the pip line in the generated requirements. The display format is a dropdown in the inspector, and the handler stub reads the value the way that survives a format change.

Lay the window out visually and read the generated Python as you go.

Open the tkinter designer →

Related questions