Spaces:
Sleeping
Sleeping
import streamlit as st | |
# μ¬μ΄λλ° νμ΄ν | |
st.sidebar.title("μ μ΄μ λ©λ΄") | |
# λ©λ΄ νλͺ©κ³Ό νμ νλͺ© μ μ | |
menus = { | |
"Display": ["Display text", "Display interactive widgets", "Display data", "Display media", "Display code", "Display progress and status"], | |
"Data": ["Connect to data sources", "Mutate data", "Placeholders, help, and options"], | |
"Control": ["Optimize performance", "Cache global resources", "Deprecated caching"], | |
"Layout": ["Columns", "Tabs", "Control flow"], | |
"Interactivity": ["Build chat-based apps", "Personalize apps for users"], | |
} | |
selected_menu = None | |
# κ° λ©λ΄μ λν΄ μ¬μ΄λλ°μ μ μ΄μ λ©λ΄ μμ± | |
for menu in menus: | |
with st.sidebar.expander(menu): | |
for sub_menu in menus[menu]: | |
if st.button(sub_menu, key=sub_menu): # κ³ μ ν keyλ₯Ό μ 곡νμ¬ κ° λ²νΌμ κ΅¬λ³ | |
selected_menu = sub_menu | |
break | |
# μ νλ λ©λ΄μ λ°λ₯Έ λμ ꡬν | |
if 'selected_menu' in locals(): | |
if selected_menu == "Display interactive widgets": | |
# μ¬λΌμ΄λ μμ ―μ μ¬μ©νκ³ λ°ν κ°μ slider_val λ³μμ μ μ₯ | |
slider_val = st.slider('Slide me', min_value=0, max_value=10) | |
# μ μ₯λ slider_val λ³μ κ°μ μ¬μ©νμ¬ μΆλ ₯ | |
st.write(f"μ¬λΌμ΄λμ κ°: {slider_val}") | |
st.text('Fixed width text') | |
st.markdown('_Markdown_') # see #* | |
st.caption('Balloons. Hundreds of them...') | |
st.latex(r''' e^{i\pi} + 1 = 0 ''') | |
st.write('Most objects') # df, err, func, keras! | |
st.write(['st', 'is <', 3]) # see * | |
st.title('My title') | |
st.header('My header') | |
st.subheader('My sub') | |
st.code('for i in range(8): foo()') | |
elif selected_menu == "Display interactive widgets": | |
# Interactive widgets | |
button_clicked = st.button('Hit me') | |
checkbox_checked = st.checkbox('Check me out') | |
radio_option = st.radio('Pick one:', ['nose', 'ear']) | |
selectbox_option = st.selectbox('Select', [1, 2, 3]) | |
multiselect_options = st.multiselect('Multiselect', [1, 2, 3]) | |
slider_value = st.slider('Slide me', min_value=0, max_value=10) | |
select_slider_option = st.select_slider('Slide to select', options=[1, '2']) | |
text_input = st.text_input('Enter some text') | |
number_input = st.number_input('Enter a number') | |
text_area = st.text_area('Area for textual entry') | |
date_input = st.date_input('Date input') | |
time_input = st.time_input('Time entry') | |
file_uploader = st.file_uploader('File uploader') | |
color_picker = st.color_picker('Pick a color') | |