liveBook · Manning

Widget

As explained in Python How-To

A widget is a self-contained user-interface component that displays information or provides an interaction.

A widget is a self-contained interface element that displays information or accepts user interaction. In Streamlit, widgets let a Python script provide buttons, text inputs, choices, numeric controls, multimedia, and date or time controls while the framework handles layout. section 14.4.1

Use widgets to build practical web-app interactions:

  • Create controls such as buttons, radio choices, filters, and text inputs by specifying the widget type and its configuration. section 14.4.1
  • Organize related elements with st.columns([3, 1]); the returned column references can receive widgets such as a View Detail button. section 14.4.5
  • Use widget input to retrieve filtering parameters, sort tasks, and display the resulting data. section 14.4.5
  • Account for Streamlit rerunning the entire script from top to bottom when an input changes; session state provides a workaround for some use cases. section 14.4.1

Task-management interface

A task list places each task beside a View Detail button. Columns provide a 3:1 layout ratio, while the button receives the task identifier and calls wants_task_detail with the task as an argument. Sidebar widgets configure status, urgency, and content filters; the main area then shows the matching tasks. section 14.4.5 section 14.4.2

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.
CH14_F06_Cui

Browse the widget categories: clickable controls, single or multiple choice, numeric data, textual data, multimedia, and date and time. section 14.4.1

How Python How-To covers it

How deep it goes
Defines widget categories and demonstrates configuration, columns, filtering, callbacks, and reruns, while deferring detailed widget usage instructions.
Examples
Uses task filters, a View Detail button, sidebar controls, columns, task forms, and interfaces for creating, updating, and deleting tasks.
What it assumes
Assumes familiarity with Python scripts and basic application data, while introducing Streamlit’s widget-driven interface model.
What you can do after
Apply it via Streamlit to construct interactive task-list, detail, filtering, and data-entry interfaces.
How it connects
Connects widgets with Streamlit, web applications, automatic layout, callbacks, session state, forms, sorting, and filtering.

Also explained in

Compare how 2 books explain widget →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Python How-To. The section links point to the parts of the book it draws on.