Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Adding Interactivity with Widgets | Section
Practice
Projects
Quizzes & Challenges
Quizzen
Challenges
/
Building Dashboards with Streamlit

bookAdding Interactivity with Widgets

To make your dashboards interactive and responsive to user input, Streamlit provides a variety of widgets. These widgets allow users to control parameters, filter data, or provide information directly through the app interface. Some of the most commonly used widgets include st.slider, st.selectbox, and st.text_input.

  • The st.slider widget lets users select a numeric value or range by moving a slider;
  • The st.selectbox allows users to choose a single option from a dropdown list;
  • The st.text_input widget enables users to enter freeform text.

By incorporating these widgets, you can build dashboards that react instantly to user choices, making the data exploration experience much more engaging and tailored.

In this example, the st.slider widget gives users control over the number of bins in the histogram. When a user moves the slider, the value of num_bins updates instantly. This value is then used to set the bins parameter in the ax.hist function, which redraws the histogram with the new bin count. As a result, the chart displayed in the dashboard updates in real time based on the user's selection, demonstrating how widget values can be directly used to make dashboard content interactive and dynamic.

question mark

Which Streamlit widget allows users to select a numeric value or range by moving a slider?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 4

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

bookAdding Interactivity with Widgets

Veeg om het menu te tonen

To make your dashboards interactive and responsive to user input, Streamlit provides a variety of widgets. These widgets allow users to control parameters, filter data, or provide information directly through the app interface. Some of the most commonly used widgets include st.slider, st.selectbox, and st.text_input.

  • The st.slider widget lets users select a numeric value or range by moving a slider;
  • The st.selectbox allows users to choose a single option from a dropdown list;
  • The st.text_input widget enables users to enter freeform text.

By incorporating these widgets, you can build dashboards that react instantly to user choices, making the data exploration experience much more engaging and tailored.

In this example, the st.slider widget gives users control over the number of bins in the histogram. When a user moves the slider, the value of num_bins updates instantly. This value is then used to set the bins parameter in the ax.hist function, which redraws the histogram with the new bin count. As a result, the chart displayed in the dashboard updates in real time based on the user's selection, demonstrating how widget values can be directly used to make dashboard content interactive and dynamic.

question mark

Which Streamlit widget allows users to select a numeric value or range by moving a slider?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 4
some-alt