import streamlit as st import numpy as np import pandas as pd import time # 사이드바 타이틀 st.sidebar.title("접이식 메뉴") # 메뉴 항목과 하위 항목 정의 menus = { "Display": ["Display text", "Display interactive widgets", "Display data", "Display media", "Display code", "Display progress and status"], "B": ["Connect to data sources", "Mutate data", "Placeholders, help, and options"], "C": ["Optimize performance", "Cache global resources", "Deprecated caching"], "D": ["Columns", "Tabs", "Control flow"], "E": ["Build chat-based apps", "Personalize apps for users"], } # 각 메뉴에 대해 사이드바에 접이식 메뉴 생성 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 text": 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": if st.button('Hit me'): st.write('Button clicked!') data = {'first_col': [1, 2, 3, 4], 'second_col': [10, 20, 30, 40]} df = pd.DataFrame(data) # st.data_editor('Edit data', df) # 'st.data_editor' does not exist in Streamlit's current version. st.checkbox('Check me out') st.radio('Pick one:', ['nose', 'ear']) st.selectbox('Select', [1, 2, 3]) st.multiselect('Multiselect', [1, 2, 3]) st.slider('Slide me', min_value=0, max_value=10) st.select_slider('Slide to select', options=[1, '2']) st.text_input('Enter some text') st.number_input('Enter a number') st.text_area('Area for textual entry') st.date_input('Date input') st.time_input('Time entry') # st.file_uploader('File uploader') # Example does not provide data for 'st.audio', 'st.video', 'st.download_button', etc. # st.download_button('On the dl', data) # Example does not provide data for this function. # st.camera_input("一二三,茄子!") # 'st.camera_input' does not exist in Streamlit's current version. st.color_picker('Pick a color') # The rest of the elif blocks for other sub-menus would be similar to above, # implementing the functionality as per the chosen sub-menu item. # Note: Some of the example commands provided do not match with actual Streamlit API functions # or require context that's not provided, and thus have been commented out or slightly modified.