Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to retains the values selected in previous tab if the users switch b/w the tabs #15

Open
Ranji-1712 opened this issue Nov 15, 2024 · 0 comments

Comments

@Ranji-1712
Copy link

Not able to retains the values selected in previous tab if the users switch b/w the tabs

`from st_on_hover_tabs import on_hover_tabs
import streamlit as st

Initialize session state variables if they are not already set

if 'source_connection' not in st.session_state:
st.session_state['source_connection'] = None

if 'hover_tab' not in st.session_state:
st.session_state['hover_tab'] = 'Table Config'

st.session_state['source_tables_config'] = ['Test1', 'Test2']

Sidebar with hover tabs

with st.sidebar:
hover_tabs = on_hover_tabs(tabName=['Table Config', 'Validations', 'Test Report', 'Others'],
iconName=['engineering', 'rule', 'receipt long', 'share'], default_choice=0)
st.session_state['hover_tab'] = hover_tabs

Display content based on the selected tab

if st.session_state['hover_tab'] == 'Table Config':
st.session_state['source_connections'] = sorted(st.session_state['source_tables_config'])
st.selectbox(
':violet[Select Source Database Name :red[*]]',
st.session_state['source_connections'],
index=None,
placeholder="Source Databases",
key='source_connection'
)

elif st.session_state['hover_tab'] == 'Test Report':
# Add your code for the 'Test Report' tab here
st.write("Test Report content goes here.")
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant