Seperate Functions to Buttons

Hello,

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?

Hey @arwa,

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:
Screen Shot 2020-11-25 at 2.39.57 PM

Happy Streamlit-ing!
Marisa

Hi! for styling purposes yes I have to do the button way. Thank you for your help