Skip to content

TimeEntry

TimeEntry is a form-ready input control for entering a time of day.

It's built on the same field foundation as other v2 inputs, so it supports a label and message region, validation, localization/formatting, and consistent events.


Quick start

import bootstack as bs

app = bs.App()

t = bs.TimeEntry(
    app,
    label="Start time",
    value="08:30",
)
t.pack(fill="x", padx=20, pady=10)

app.mainloop()

When to use

Use TimeEntry when:

  • users need to enter times (schedules, appointments, thresholds)

  • you want consistent field behavior (label, message, validation, events)

Consider a different control when:

  • the value is not semantically a time — use TextEntry

  • you want free-form text — use TextEntry

  • users should step through time in fixed increments (minutes, hours) — use SpinnerEntry


Appearance

accent

bs.TimeEntry(app, label="Start time")  # primary (default)
bs.TimeEntry(app, label="Start time", accent="secondary")
bs.TimeEntry(app, label="Start time", accent="success")
bs.TimeEntry(app, label="Start time", accent="warning")

Examples and patterns

Value model

TimeEntry separates typed text from the committed time value.

  • While editing, the widget contains raw text.

  • On commit (blur or Enter), the value is parsed and normalized.

current = t.value  # committed value
raw = t.get()      # raw text

If parsing fails, the value remains unchanged and validation/event feedback is emitted (see Validation).

Common options

Common field options include:

  • label, message, required

  • accent

  • value (initial committed value)

  • time formatting options (if supported by your implementation)

bs.TimeEntry(app, label="End time", required=True, accent="secondary")

Events

TimeEntry follows the standard field event model:

  • <<Input>> / on_input — live typing

  • <<Changed>> / on_changed — committed value changed

  • <<Valid>>, <<Invalid>>, <<Validated>> — validation lifecycle

def on_changed(event):
    print("time:", event.data["value"])

t.on_changed(on_changed)

Validation

Validation is commonly used to ensure:

  • the value is a valid time

  • a time is required

  • time ranges are consistent across fields (e.g., start < end)

Because TimeEntry is a structured input, prefer commit-time validation rather than per-keystroke restrictions.


Behavior

TimeEntry is designed for quick keyboard entry:

  • users can type a time (e.g., 830, 8:30, 08:30, depending on your parser)

  • commit occurs on blur or Enter

  • formatting (if configured) is applied on commit

If your implementation supports a picker-style interaction, it should be treated as an optional convenience on top of typing.


Formatting and localization

TimeEntry supports locale-aware time formatting through the value_format option. Times are displayed according to the current locale's conventions (12-hour vs 24-hour format, AM/PM indicators).

bs.TimeEntry(app, label="Short Time", value_format="shortTime")  # "3:30 PM"
bs.TimeEntry(app, label="Long Time", value_format="longTime")    # "3:30:45 PM PST"
bs.TimeEntry(app, label="24-Hour", value_format="HH:mm")         # "15:30"

See Guides → Formatting for all time presets and custom patterns.


Reactivity

TimeEntry integrates with the signals system for reactive data binding. Changes to the field value can automatically propagate to other parts of your application.


Additional resources

  • DateEntry — date input control
  • TextEntry — general field control
  • NumericEntry — numeric field with bounds and stepping
  • SpinnerEntry — stepped input control (useful for minute increments)
  • Form — build forms from field definitions

Framework concepts

API reference