streamlit4c / app.py
seawolf2357's picture
Update app.py
6e8c858 verified
raw
history blame
815 Bytes
import streamlit as st
# μ‚¬μ΄λ“œλ°” 타이틀
st.sidebar.title("접이식 메뉴")
# 메뉴 ν•­λͺ©κ³Ό ν•˜μœ„ ν•­λͺ© μ •μ˜
menus = {
"A": ["A-1", "A-2", "A-3"],
"B": ["B-1", "B-2", "B-3"],
"C": ["C-1", "C-2", "C-3"],
"D": ["D-1", "D-2", "D-3"],
"E": ["E-1", "E-2", "E-3"],
}
# μ„ νƒλœ 메뉴λͺ…을 μ €μž₯ν•  λ³€μˆ˜
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
# μ„ νƒλœ 메뉴λͺ… 좜λ ₯
if selected_menu:
st.write(f"μ„ νƒλœ 메뉴: {selected_menu}")
else:
st.write("메뉴λ₯Ό μ„ νƒν•΄μ£Όμ„Έμš”.")