tk_date_entry
tk_date_entry is a lightweight, dependency-free Tkinter DateEntry widget
with a drop-down calendar.
The widget provides a single-line entry showing a date in a configurable format, with a drop-down calendar popup for visual date selection.
Key Features
-
Drop-down calendar popup
A calendar popup opens below (or above, if there is no room) the entry, allowing visual selection of a day. The popup closes with the drop-down button (toggle), the
Escapekey, a click outside the popup, or when the application window loses the foreground. -
Full keyboard and mouse navigation
Month and year navigation with arrows and comboboxes, month/year selector views, keyboard support on the entry, and tooltips showing the full localized date when hovering over a day.
-
Configurable date format
Any
strftime-compatible pattern viadate_pattern(default%Y-%m-%d), with live validation of typed dates. -
Localization
Month and weekday names follow the current locale, or the one specified with the
localeparameter. -
Date range validation
Optional
mindateandmaxdatelimits; out-of-range values are rejected (raisingValueErrorwhenraise_exceptionis set, or reported in-line otherwise). -
Weekend and weekday customization
Configurable weekend days (
weekenddays), first day of the week (first_weekday), optional week numbers (show_week_numbers) and optional days of adjacent months (show_other_month_days). -
Robust popup behavior
The popup follows the application window when moved, never floats above unrelated applications, returns the focus to the entry when closed, and works consistently on Windows (including with
overrideredirectwindows), macOS and Linux. -
Zero dependencies
No third-party packages required: only the Python standard library.
Installation
Requires Python 3.9 or later (including Python 3.14).
pip install tk-date-entry
Usage
Basic usage with default settings
import tkinter as tk
from tk_date_entry import DateEntry
root = tk.Tk()
root.title("DateEntry demo")
de = DateEntry(root, date_pattern="%Y-%m-%d")
de.pack(padx=20, pady=20)
root.mainloop()
Complete example with all options
import tkinter as tk
from datetime import date
from tk_date_entry import DateEntry
root = tk.Tk()
root.title("DateEntry")
de = DateEntry(
root,
date_pattern="%d/%m/%Y", # display format
first_weekday=0, # 0 = Monday
locale=None, # None = system locale
mindate=date(2020, 1, 1), # minimum allowed date
maxdate=date(2030, 12, 31),# maximum allowed date
weekenddays=(5, 6), # Saturday and Sunday
show_week_numbers=False, # show the week number column
show_other_month_days=False, # grey days of adjacent months
validate=True, # validate typed dates
raise_exception=False, # report invalid dates in-line
)
de.pack(padx=20, pady=20)
def show():
print("Selected:", de.get_date())
tk.Button(root, text="Get date", command=show).pack(pady=5)
root.mainloop()
API summary
DateEntry(
master,
date_pattern="%Y-%m-%d",
first_weekday=0,
value=None,
locale=None,
mindate=None,
maxdate=None,
weekenddays=(5, 6),
show_week_numbers=False,
show_other_month_days=False,
validate=True,
raise_exception=False,
**kwargs,
)
| Method | Description |
|---|---|
get_date() |
Return the currently set date as a datetime.date, or None if empty. |
set_date(value) |
Set the date (datetime.date, datetime.datetime, str or None). |
get() |
Return the date as a string formatted with date_pattern. |
set(value) |
Alias of set_date() accepting a string. |
clear() |
Clear the entry. |
drop_down() |
Open/close the calendar popup (toggle). |
state(statespec) |
ttk-compatible state management (e.g. ['disabled']). |
Limitations
The calendar popup is a borderless Toplevel window. On Windows,
overrideredirect windows do not receive focus events, so the widget uses a
very light polling (a single Win32 call every 300 ms, only while the popup is
open) to detect when the application loses the foreground and close the
popup. On macOS and Linux the window manager handles this natively and no
polling is performed.
License
EUPL-1.2 License - See LICENSE for details.
Metadata
Release files for tk-date-entry 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tk_date_entry-1.1.0.tar.gz | 21.3 kB | Details |
Release files / tk_date_entry-1.1.0.tar.gz
| Download URL | tk_date_entry-1.1.0.tar.gz |
|---|---|
| Size | 21.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
90ad7f3acf7206453e03a8d1bf191432f04afa24e46782192a866c87a070b183
|
|
BLAKE2b-256 checksum How to use checksums |
d587686e3eaff89f6150706bff886b1015f4701fc948db3812cbd80e86c99c84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|