Skip to content

DateEntry

Bases: Field

A date entry field widget with calendar picker button.

DateEntry extends the Field widget to provide specialized date input with locale-aware formatting and an optional calendar picker button. The widget supports various date format presets and custom ICU date format patterns, and can accept input as strings, date objects, or datetime objects.

The available date format presets are: longDate (January 15, 2025), shortDate (1/15/25), monthAndDate (January 15), monthAndYear (January 2025), quarterAndYear (Q1 2025), day (15), dayOfWeek (Wednesday), month (January), quarter (Q1), year (2025), longTime (3:30:45 PM PST), shortTime (3:30 PM), longDateLongTime, shortDateShortTime, or any custom ICU date format pattern (e.g., "yyyy-MM-dd").

Events

  • <<Change>>: Fired when date value changes after commit.
  • <<Input>>: Fired on each keystroke.
  • <<Valid>>: Fired when validation passes.
  • <<Invalid>>: Fired when validation fails.

The calendar picker button uses a DateDialog. The button can be hidden using show_picker_button=False.

Attributes:

Name Type Description
entry_widget TextEntryPart

Access to the underlying TextEntryPart widget.

label_widget Label

Access to the label widget.

message_widget Label

Access to the message label widget.

addons dict

Dictionary of inserted addon widgets.

variable Variable

Tkinter Variable linked to entry text.

signal Signal

Signal object for reactive updates.

date_picker_button Button

The calendar picker button widget.

date_picker_button property

date_picker_button

Get the calendar picker button widget.

__init__

__init__(
    master: Master = None,
    value: str | date | datetime = None,
    value_format: str = "longDate",
    label: str = None,
    message: str = None,
    show_picker_button=True,
    picker_title: str = "Select new date",
    picker_first_weekday: int = 6,
    **kwargs: Unpack[FieldOptions],
)

Initialize a DateEntry widget.

Creates a date entry field with locale-aware formatting and an optional calendar picker button. The widget accepts date input as strings, date objects, or datetime objects, and formats them according to the specified value_format pattern.

Parameters:

Name Type Description Default
master Master

Parent widget. If None, uses the default root window.

None
value str | date | datetime

Initial date value to display. Can be a date object, datetime object, or string representation.

None
value_format str

Date format pattern to use for parsing and displaying dates. See class docstring for complete list of presets.

'longDate'
label str

Optional label text to display above the entry field. If required=True, an asterisk (*) is automatically appended.

None
message str

Optional message text to display below the entry field. Used for hints or help text. Replaced by validation errors when validation fails.

None
show_picker_button bool

If True, displays the calendar picker button to the right of the entry. If False, hides the button.

True
picker_title str

Title text for the calendar picker dialog.

'Select new date'
picker_first_weekday int

First day of the week to display in the calendar picker. 0=Monday, 6=Sunday.

6

Other Parameters:

Name Type Description
locale str

Locale identifier for date formatting (e.g., 'en_US').

required bool

If True, field cannot be empty.

bootstyle str

The accent color of the focus ring and active border.

allow_blank bool

Allow empty input.

cursor str

Cursor style when hovering.

exportselection bool

Export selection to clipboard.

font str

Font for text display.

foreground str

Text color.

initial_focus bool

If True, widget receives focus on creation.

justify str

Text alignment ('left', 'center', 'right').

show_message bool

If True, displays message area.

padding int | tuple

Padding around entry widget.

takefocus bool

If True, widget accepts Tab focus.

textvariable Variable

Tkinter Variable to link with text.

textsignal Signal

Signal object for reactive updates.

width int

Width in characters.

xscrollcommand Callable

Callback for horizontal scrolling.

Note

The widget uses the IntlFormatter for locale-aware date formatting. The value is parsed and formatted automatically when the user commits input (on FocusOut or Return key). Invalid date strings that cannot be parsed will revert to the previous valid value.