Skip to main content

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 Escape key, 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 via date_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 locale parameter.

  • Date range validation

    Optional mindate and maxdate limits; out-of-range values are rejected (raising ValueError when raise_exception is 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 overrideredirect windows), 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.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tk-date-entry 1.0.0
File Size Uploaded
tk_date_entry-1.0.0.tar.gz 20.8 kB Details

Release files / tk_date_entry-1.0.0.tar.gz

Download URL tk_date_entry-1.0.0.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5cd98e429b6a1ef29a994390894442fc3426b8b1710c0017b5fe8805a4df5778
BLAKE2b-256 checksum
How to use checksums
3a5a336417a341d650c7c495c58a712279f826004474a0a5b7f01269f9181b22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

1.1.0

1 release file

This release

1.0.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page