A widget is a user-interface element that displays information or lets someone interact with an app. In Streamlit, you specify a widget’s type and configuration; the framework handles the layout. When a user changes an input, Streamlit reruns the script from top to bottom. Session state can help address cases where that behavior is inconvenient. section 14.4.1 section 14.4.1
In a task manager, widgets can collect sorting and filtering choices, organize task content into columns, and let users open a task’s details. A button click can trigger an action such as displaying the selected task. section 14.4.5
Figure 14.6 The available widgets in the streamlit framework. The six categories are Clickable (buttons), Single or Multiple Choice, Numeric Data, Textual Data, Multimedia, and Date and Time.
Browse Streamlit widget categories, from buttons and choices to text, multimedia, and date-and-time inputs. section 14.4.1
Listing 14.11 Showing the tasks in the web app
def show_tasks():
filter_params = session[sorting_params_key]
if filter_params[TaskierFilterKey.SORTING_KEY.value] is not None:
reading_params = get_reading_params(filter_params)
tasks = Task.load_tasks(**reading_params)
sorting_key = sorting_keys[filter_params[
TaskierFilterKey.SORTING_KEY.value]]
should_reverse = filter_params[
TaskierFilterKey.SORTING_ORDER.value] == sorting_orders[1]
tasks.sort(key=lambda x: getattr(x, sorting_key),
reverse=should_reverse)
else:
tasks = Task.load_tasks() #1
for task in tasks:
col1, col2 = st.columns([3, 1]) #2
col1.write(str(task))
col2.button("View Detail", key=task.task_id,
on_click=wants_task_detail, args=(task,))
st.write(f"Status: {task.status.name.title()}")
st.markdown("___") #3
See a task-list example that uses columns and a button to display task information and open details. section 14.4.5

