I currently have the following problem with the tabs. I added two tabs on my page and in both select boxes as an example. If I change the select box in Tab 2, the program jumps back to Tab 1.
I know I can use a form with a button. However, as soon as the button is pressed and a function is executed in the background, the program also jumps back to Tab 1.
I don’t think this can be intentional. How can I stop this behavior? Is there a way to read and cache the index of the tabs?
Here is some example code:
tab1, tab2 = st.tabs(option_menu_database) with tab1: st.header("View") with st.form("database_view"): db_tables = pd.DataFrame(database_tables()) selected_table = st.selectbox("Tables",db_tables) if st.form_submit_button("Load tables"): db_table = pd.DataFrame(database_get_table(selected_table)) st.write(db_table) with tab2: st.subheader("Edit") with st.form("database_edit"): select_choice = st.selectbox("What do you want to edit?",("Database","Table")) if st.form_submit_button("Load"): db_tables = pd.DataFrame(database_get_table(select_choice)) selected_table = st.selectbox("Tables",db_tables) st.markdown("---")
I hope you can help me.
Thanks in advance!