TimeEntry
Bases: SelectBox
Time entry field with dropdown list of time intervals.
TimeEntry extends SelectBox to provide specialized time input with locale-aware formatting and a searchable dropdown of time intervals. The widget supports various time format presets and custom time patterns.
Events
<<Change>>: Fired when time value changes after commit.<<Input>>: Fired on each keystroke.<<Valid>>: Fired when validation passes.<<Invalid>>: Fired when validation fails.
Attributes:
| Name | Type | Description |
|---|---|---|
entry_widget |
TextEntryPart
|
The underlying text entry widget. |
label_widget |
Label
|
The label widget above the entry. |
message_widget |
Label
|
The message label widget below the entry. |
addons |
dict[str, Widget]
|
Dictionary of inserted addon widgets by name. |
variable |
Variable
|
Tkinter Variable linked to entry text. |
signal |
Signal
|
Signal object for reactive updates. |
__init__
__init__(
master: Master = None,
value: Union[time, str] = None,
value_format: str = "shortTime",
interval: int = 30,
min_time: Union[time, str] = None,
max_time: Union[time, str] = None,
label: str = None,
message: str = None,
**kwargs: Unpack[FieldOptions],
)
Initialize a TimeEntry widget.
Creates a time entry field with locale-aware formatting and a searchable dropdown of time intervals. The widget accepts time input as time objects or strings, 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
|
Union[time, str]
|
Initial time value to display. Can be a time object or string. Default is current time. |
None
|
value_format
|
str
|
Time format pattern for parsing and displaying times. Default is "shortTime" (e.g., "3:30 PM"). Common formats: "shortTime" (3:30 PM), "longTime" (3:30:45 PM PST), "mediumTime" (3:30:45 PM), "HH:mm" (15:30), "h:mm a" (3:30 PM). |
'shortTime'
|
interval
|
int
|
Time interval in minutes for dropdown items (e.g., 15, 30, 60). Default is 30 minutes. |
30
|
min_time
|
Union[time, str]
|
Minimum time value for the dropdown list. Can be a time object or string (e.g., "09:00" or "9:00 AM"). Default is midnight (00:00). |
None
|
max_time
|
Union[time, str]
|
Maximum time value for the dropdown list. Can be a time object or string (e.g., "17:00" or "5:00 PM"). Default is 11:59 PM (23:59). |
None
|
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
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
locale |
str
|
Locale identifier for time formatting (e.g., 'en_US'). |
required |
bool
|
If True, field cannot be empty. |
color |
str
|
Color token for the focus ring and active border. |
bootstyle |
str
|
DEPRECATED - Use |
allow_blank |
bool
|
Allow empty input. |
width |
int
|
Width in characters. |
textvariable |
Variable
|
Tkinter Variable to link with text. |
textsignal |
Signal
|
Signal object for reactive updates. |
Note
The widget uses IntlFormatter for locale-aware time formatting. The dropdown is searchable - type to filter time values. Custom time values can be entered directly in the field.