streamlit4c / app.py
seawolf2357's picture
Update app.py
9803273 verified
raw
history blame
2.68 kB
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')