import streamlit as st
import utilities as utils
import datetime
# Convert Dataset into Dict
tickers = utils.get_tickers()
# Set title
st.title("Hello World")
st.write('\n')
def submit_handler():
tab1, tab2 = st.tabs(['Performance','Risks'])
with tab1:
st.write('This is tab 1')
with tab2:
st.write('This is tab 2')
with st.sidebar:
st.button('Submit',on_click=submit_handler)
Because the on_click
argument is a callback and those are run before the app is rendered back again. Check the Use Callbacks to update Session State section from the docs:
And a more in depth guide:
Imo if-statements are more readable in those cases where callbacks are not really necessary:
with st.sidebar:
if st.button('Submit'):
submit_handler()
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.