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
Name | Description | Type |
---|---|---|
label | The label to display to the user | str |
slots | The available slots for the user to choose from | List[Union[AppointmentSlot, dict, Tuple[datetime, datetime]]] |
initial_value | The initial value to display to the user. Defaults to None. | Union[AppointmentSlot, dict, Tuple[datetime, datetime]] |
disabled | whether the input is disabled. Defaults to False. | bool |
required | Whether the input is required or not eg. "this field is required". Defaults to True. | Union[bool, str] |
hint | A tooltip displayed to the user. Defaults to None. | str |
full_width | Whether the input should use full screen width. Defaults to False. | bool |
button_text | What text to display on the button when the widget is not part of a Page. Defaults to 'Next'. | str |
Return Values
Type | Description |
---|---|
AppointmentSlot | A dict containing the selected appointment slot |