Skip to content

DateDialog

Modal dialog that displays a Calendar

result property

result: Optional[date]

The selected date, or None if cancelled.

__init__

__init__(
    master: Optional[Misc] = None,
    title: str = " ",
    initial_date: Optional[date] = None,
    first_weekday: int = 6,
    accent: str = None,
    disabled_dates: Optional[
        Iterable[date | datetime | str]
    ] = None,
    min_date: Optional[date | datetime | str] = None,
    max_date: Optional[date | datetime | str] = None,
    show_outside_days: Optional[bool] = None,
    show_week_numbers: bool = False,
    hide_window_chrome: bool = False,
    close_on_click_outside: bool = False,
) -> None

Create a date selection dialog.

Parameters:

Name Type Description Default
master Optional[Misc]

Parent widget; positions dialog relative to it when set.

None
title str

Dialog window title text.

' '
initial_date Optional[date]

Initial date shown; defaults to date.today().

None
first_weekday int

First weekday index (0=Monday, 6=Sunday).

6
accent str

Calendar accent token (e.g., primary, secondary).

None
disabled_dates Optional[Iterable[date | datetime | str]]

Iterable of dates to disable selection.

None
min_date Optional[date | datetime | str]

Lower bound for selectable dates.

None
max_date Optional[date | datetime | str]

Upper bound for selectable dates.

None
show_outside_days Optional[bool]

Whether to show outside-month days. Defaults to the Calendar behavior (True for single month).

None
show_week_numbers bool

Display ISO week numbers beside each row.

False
hide_window_chrome bool

When True, displays the dialog with no window decorations using override-redirect.

False
close_on_click_outside bool

When True, closes the dialog when focus moves outside (popover mode).

False

show

show(
    position: Optional[Tuple[int, int]] = None,
    modal: Optional[bool] = None,
    *,
    anchor_to: Optional[
        Union[Widget, Literal["screen", "cursor", "parent"]]
    ] = None,
    anchor_point: AnchorPoint = "center",
    window_point: AnchorPoint = "center",
    offset: Tuple[int, int] = (0, 0),
    auto_flip: Union[
        bool, Literal["vertical", "horizontal"]
    ] = False,
) -> None

Display the dialog and block until closed.

Parameters:

Name Type Description Default
position Optional[Tuple[int, int]]

Optional (x, y) coordinates to position the dialog. If provided, takes precedence over anchor-based positioning. If omitted and anchor_to is not provided, positions at the parent's bottom-right when available, otherwise centers.

None
modal Optional[bool]

Override the mode's default modality. If None, uses True for modal mode dialogs.

None
anchor_to Optional[Union[Widget, Literal['screen', 'cursor', 'parent']]]

Positioning target. Can be: - Widget: Anchor to a specific widget - "screen": Anchor to screen edges/corners - "cursor": Anchor to mouse cursor location - "parent": Anchor to parent window (same as widget) - None: Uses default positioning behavior

None
anchor_point AnchorPoint

Point on the anchor target (n, s, e, w, ne, nw, se, sw, center). Default 'center'.

'center'
window_point AnchorPoint

Point on the dialog window (n, s, e, w, ne, nw, se, sw, center). Default 'center'.

'center'
offset Tuple[int, int]

Additional (x, y) offset in pixels from the anchor position.

(0, 0)
auto_flip Union[bool, Literal['vertical', 'horizontal']]

Smart positioning to keep window on screen. - False: No flipping (default) - True: Flip both vertically and horizontally as needed - 'vertical': Only flip up/down - 'horizontal': Only flip left/right

False

on_result

on_result(
    callback: Callable[[date], None],
) -> Optional[str]

Bind a callback fired when a result is produced.

The callback receives event.data["result"] (a datetime.date).

Parameters:

Name Type Description Default
callback Callable[[date], None]

Callable that receives the selected datetime.date.

required

Returns:

Type Description
Optional[str]

The Tk binding identifier, which can be used with off_result.

off_result

off_result(funcid: str) -> None

Unbind a previously bound on_result callback.

Parameters:

Name Type Description Default
funcid str

Binding identifier returned by on_result.

required