Skip to main content

Appointment Input

A calendar slot selection that allows users to select a time slot for an appointment.

Examples

Basic Example

A simple appointment booking selector

from datetime import datetime, timedelta

from abstra.forms import read_appointment

# next 14 days
# only weekdays
# 10:00 - 18:00
# 15 minutes interval
# 45 minutes duration
# remove lunch break
slots = []
max_date = datetime.now() + timedelta(days=14)
current_date = datetime.now()
while current_date < max_date:
if current_date.weekday() < 5:
for hour in range(10, 18):
if hour == 12:
continue
begin = current_date.replace(hour=hour, minute=0)
end = begin + timedelta(minutes=45)
slots.append((begin, end))
current_date += timedelta(days=1)
read_appointment("Welcome to Abstra, please select a demo slot", slots=slots)

Parameters

NameDescriptionType
labelThe label to display to the userstr
slotsThe available slots for the user to choose fromList[Union[AppointmentSlot, dict, Tuple[datetime, datetime]]]
initial_valueThe initial value to display to the user. Defaults to None.Union[AppointmentSlot, dict, Tuple[datetime, datetime]]
disabledwhether the input is disabled. Defaults to False.bool
requiredWhether the input is required or not eg. "this field is required". Defaults to True.Union[bool, str]
hintA tooltip displayed to the user. Defaults to None.str
full_widthWhether the input should use full screen width. Defaults to False.bool
button_textWhat text to display on the button when the widget is not part of a Page. Defaults to 'Next'.str

Return Values

TypeDescription
AppointmentSlotA dict containing the selected appointment slot