Data Application with button

Hey,

I am creating a data application having multiple buttons and each button serves a particular function, So after I ran the application I get the buttons and when you like click the 2nd, 3rd etc., buttons the whole code reruns. Can you please let me know if there is a way to like isolate the 2nd button to run only that part of code instead of running 1st and 2nd.

Hello @digi_that, welcome to the community :slight_smile:

If I understood your issue correctly, since st.button returns True when you click it and None when another button is clicked, you could wrap this event inside an if condition :

import streamlit as st 

if st.sidebar.button("Click me"):
    st.markdown("I'm button 1")

if st.sidebar.button("No click me"):
    st.markdown("I'm button 2")

if st.sidebar.button("Click me 3"):
    st.markdown("I'm button 3")