Hello Streamlit Community,
I’m encountering a peculiar issue with the TabBar
component from the extra_streamlit_components
library, where it disappears every time I refresh the page. However, this behavior only occurs when login-related features are enabled in my application. If I disable these login functionalities, the TabBar
remains visible and functions as expected upon page refresh.
Here’s a brief overview of my situation:
- The
TabBar
is implemented usingextra_streamlit_components.TabBarItemData
to define tabs, with a default tab specified and a unique key for each instance. - I’m managing the state of the selected tab using Streamlit’s session state, aiming to preserve the tab selection across page refreshes.
- The issue arises when login features are integrated. Without these login functionalities, the
TabBar
works perfectly fine, even after refreshing the page.
Given this, I’ve checked that my Streamlit and extra_streamlit_components
versions are up to date, and I’ve looked for any errors in the console or network issues without finding anything that clearly indicates what’s going wrong.
Could anyone provide insights into why enabling login features would cause the TabBar
to disappear on refresh, or suggest any potential solutions to keep the TabBar
visible after a page refresh with login functionalities enabled? I would greatly appreciate any advice or tips from the community.
Thank you in advance for your help!
- first_main.py
def main():
st.set_page_config(layout="wide", page_title = 'Write your Page Title' , page_icon=":memo:")
st.header('First Page')
with st.sidebar:
config = login_module.get_conf()
login_module.login_check(config)
with st.container():
if st.session_state.get('authentication_status'):
st.write('where is tab bar')
unique_key = "tab_bar_" + str(os.getpid())
chosen_id = stx.tab_bar(data=[
stx.TabBarItemData(id="tab1", title="01.PAGE", description="description"),
stx.TabBarItemData(id="tab2", title="02.PAGE", description="description"),
stx.TabBarItemData(id="tab3", title="03.PAGE", description="description")
],default = "tab1" , key =unique_key)
data_loader = get_databricks_data()
data_loader.load_all_data()
if chosen_id == "tab1":
load_and_run_module("first_tab", "run_sum_main",data_loader)
elif chosen_id == "tab2":
load_and_run_module("second_tab", "run_anomaly_main" ,data_loader)
elif chosen_id == "tab3":
load_and_run_module("third_tab", "FirstContents" ,data_loader)
- lgn.py
import streamlit as st
import streamlit_authenticator as stauth
import yaml
from yaml.loader import SafeLoader
def get_conf():
"""
config.yaml 파일 정보 갖고오기
"""
with open('.streamlit/config.yaml') as file:
config = yaml.load(file , Loader = SafeLoader)
return config
def login_check(config):
authenticator = stauth.Authenticate(
config['credentials'],
config['cookie']['name'],
config['cookie']['key'],
config['cookie']['expiry_days'],
config['preauthorized']
)
authenticator.login()
if st.session_state['authentication_status']:
authenticator.logout()
elif st.session_state['authentication_status'] is False:
st.error('Username/password is incorrect')
st.stop()
elif st.session_state['authentication_status'] is None:
st.warning('Please enter your username and password')
st.stop()