Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Adding Interactivity with Widgets | Section
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

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 4

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

bookAdding Interactivity with Widgets

Glissez pour afficher le menu

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

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 4
some-alt