DateEntry#
DateEntry is a composite widget that ttkbootstrap ships (ttk.DateEntry)
— an Entry paired with a button that opens a calendar
popup for picking a date. The chosen date is written back into the entry, and a
<<DateEntrySelected>> virtual event fires. This page
is the complete lookup reference.
Each option can be passed to the constructor and changed later with
configure().
Options#
Option |
Type |
Description |
|---|---|---|
|
|
The focus color of the entry and the color of the date button — one of
|
|
|
The |
|
|
The first day of the week in the popup: |
|
|
The date the calendar popup focuses on when no date is selected. When
|
|
|
The initially selected date. Pass |
|
|
The Bootstrap-Icons glyph shown on the button. Default
|
|
|
Whether the popup shows the leading/trailing days of adjacent months as
muted, non-selectable labels. Default |
|
|
|
|
|
Whether an invalid typed date raises |
|
|
Optional |
|
|
Retained for API compatibility; not displayed, because the popup is
borderless. Default |
A width passed via **kwargs is applied to the entry field, not the
container frame.
Methods#
- get_date()
Return the currently selected date.
- Returns:
the selected date, or
Noneif the entry is empty / invalid.- Return type:
datetime | None
- set_date(new_date)
Set the selected date and update the entry text. Passing
Noneclears the field (equivalent toclear()).- Parameters:
new_date (datetime | date | None) – the date to display, or
Noneto clear the field.- Returns:
None.
- clear()
Clear the selected date, leaving the field empty. Afterwards
value/get_date()returnNoneand the calendar popup opens on the configuredstart_date(or today).- Returns:
None.
- enable()
Enable the entry and date button.
- Returns:
None.
- disable()
Disable the entry and date button.
- Returns:
None.
- value
The currently selected date (property; a synonym for
get_date()). AssigningNoneclears the field. ReturnsNonewhen the field is empty in the nullable model (see thevalueoption).
- enabled
Whether the date picker is currently enabled (read-only property).
Styling options#
A DateEntry is an Entry beside a button, so its
field and button follow the Entry and Button styles. The drop-down calendar has
its own style family:
Bootstyle mapping#
Any of the accent colors – primary, secondary, success, info, warning, danger, light, dark – substitutes for primary below. neutral does not apply to this family.
|
ttk style name |
|---|---|
|
|
Layout (elements)#
The widget is drawn from these nested parts. Each is an element you can target by name in a custom layout:
Toolbutton.border
Toolbutton.focus
Toolbutton.padding
Toolbutton.label
Configurable style options#
Options you can set with style.configure(...) / style.map(...):
anchor, background, bordercolor, borderwidth, compound, darkcolor, embossed, focuscolor, focussolid, focusthickness, font, foreground, image, justify, lightcolor, padding, relief, shiftrelief, space, stipple, text, underline, width, wraplength
Supported states#
The states you can target with style.map(...) to vary appearance by interaction:
!disabled, disabled, hover, pressed, selected
Hand-styling example#
import ttkbootstrap as ttk
app = ttk.App()
style = app.style
style.configure("my.TCalendar", background="#3498db", foreground="white")
# This style backs an internal/shipped widget rather than a
# directly-constructed ttk widget; configure the style class above.
See also#
DateEntry catalog page — usage, screenshots, and examples.
Entry — the native ttk entry.