Here's a breakdown of each function:
st.button('Hit me')
Displays a button labeled "Hit me" in the Streamlit app.
st.data_editor('Edit data', data)
Allows editing of data with a text editor in the Streamlit app.
st.checkbox('Check me out')
Displays a checkbox with the label "Check me out" in the Streamlit app.
st.radio('Pick one:', ['nose','ear'])
Displays a radio button group labeled "Pick one" with options "nose" and "ear" in the Streamlit app.
st.selectbox('Select', [1,2,3])
Displays a dropdown select box with options 1, 2, and 3 in the Streamlit app.
st.multiselect('Multiselect', [1,2,3])
Displays a multiselect dropdown with options 1, 2, and 3 in the Streamlit app.
st.slider('Slide me', min_value=0, max_value=10)
Displays a slider labeled "Slide me" with values ranging from 0 to 10 in the Streamlit app.
st.select_slider('Slide to select', options=[1,'2'])
Displays a select slider labeled "Slide to select" with options 1 and '2' in the Streamlit app.
st.text_input('Enter some text')
Displays a text input field labeled "Enter some text" in the Streamlit app.
st.number_input('Enter a number')
Displays a number input field labeled "Enter a number" in the Streamlit app.
st.text_area('Area for textual entry')
Displays a text area labeled "Area for textual entry" in the Streamlit app.
st.date_input('Date input')
Displays a date input field labeled "Date input" in the Streamlit app.
st.time_input('Time entry')
Displays a time input field labeled "Time entry" in the Streamlit app.
st.file_uploader('File uploader')
Displays a file uploader in the Streamlit app.
st.download_button('On the dl', data)
Displays a download button labeled "On the dl" to download the provided data in the Streamlit app.
st.camera_input("一二三,茄子!")
Allows capturing images from the camera with the specified label in the Streamlit app.
st.color_picker('Pick a color')
Displays a color picker in the Streamlit app.
Use widgets' returned values in variables
for i in range(int(st.number_input('Num:'))): foo()
This line creates a loop based on the number entered by the user in a number input widget. For each iteration of the loop, the function foo()
is called.
if st.sidebar.selectbox('I:',['f']) == 'f': b()
This line displays a select box widget in the sidebar with the options ['f']. If the user selects 'f', the function b()
is called.
my_slider_val = st.slider('Quinn Mallory', 1, 88)
This line displays a slider widget labeled 'Quinn Mallory' with values ranging from 1 to 88. The value selected by the user is stored in the variable my_slider_val
.
st.write(slider_val)
This line attempts to display the value of the variable slider_val
, but it seems to be a typo as the variable is defined as my_slider_val
. It should be st.write(my_slider_val)
to correctly display the value of the slider.
Disable widgets to remove interactivity:
st.slider('Pick a number', 0, 100, disabled=True)
This line of code creates a slider widget labeled 'Pick a number' with values ranging from 0 to 100. However, the widget is disabled, meaning that the user cannot interact with it or change its value.