Selection Widgets with Streamlit
Radio, Selectbox and Select Slider
These widgets are used when you want users to make just one selection out of several listed.
radio_selection = st.radio(“Which of these insects is not a pest?”, [“Locust”, “Lacewing”, “Leafhopper”]) if st.button(“Submit your answer”, key = “Radio”): if radio_selection == “Lacewing”: st.write(“You are correct!”) else: st.write(“You are wrong. Try again.”)
selectbox_selection = st.selectbox(“Which of these insects is a beetle?”, [“Leafhopper”, “Ladybird”, “Locust”, “Lacewing”]) if st.button(“Submit your answer”, key = “Selectbox”): if selectbox_selection == “Ladybird”: st.write(“You are ...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy