I want to make to buttons, each of them will display something if it is pressed, one of them is the default. Is it possible?
I am currently trying something like this:
import streamlit as st
import streamlit.components.v1 as components
l = st.button(“Choice A”, “something”)
k = st.button(“Choice B”)
if l:
st.write("A")
elif k:
st.write("B")
But it only shows when the button is already pressed, is there a better way of doing it?
Do you have to use the button function? I ask because this seems like a perfect example for radio buttons!
choice = st.radio('Here is a radio button', ['option 1','option 2'])
if choice == "option 1":
st.write('Here is option 1')
else:
st.write('Here is option 2')
This is ideal with what your trying to do because it will ‘default’ to the first option.
This looks like: