For example I have such a project structure:
projectName/
-
main.py
-
sidebar.py
In sidebar.py I have a class:
from streamlit import sidebar
class Sidebar:
header = sidebar.header('')
some_input = sidebar.text_input('input', value=0)
some_radio = sidebar.radio('radio', ['choice_1','choice_2'])
Code in main.py:
import streamlit as st
from sidebar import Sidebar
if __name__ == '__main__':
sb = Sidebar()
header = st.header("Main header")
Next I run my app: streamlit run main.py
Now I go to the web page and see the sidebar and header. But if I switch the radio button, the sidebar disappears.