seawolf2357 commited on
Commit
a3b9bb0
Β·
verified Β·
1 Parent(s): 89b2b74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +98 -32
app.py CHANGED
@@ -9,12 +9,14 @@ st.sidebar.title("접이식 메뉴")
9
  # 메뉴 ν•­λͺ©κ³Ό ν•˜μœ„ ν•­λͺ© μ •μ˜
10
  menus = {
11
  "Display": ["Display text", "Display interactive widgets", "Display data", "Display media", "Display code", "Display progress and status"],
12
- "B": ["Connect to data sources", "Mutate data", "Placeholders, help, and options"],
13
- "C": ["Optimize performance", "Cache global resources", "Deprecated caching"],
14
- "D": ["Columns", "Tabs", "Control flow"],
15
- "E": ["Build chat-based apps", "Personalize apps for users"],
16
  }
17
 
 
 
18
  # 각 메뉴에 λŒ€ν•΄ μ‚¬μ΄λ“œλ°”μ— 접이식 메뉴 생성
19
  for menu in menus:
20
  with st.sidebar.expander(menu):
@@ -24,7 +26,9 @@ for menu in menus:
24
  break
25
 
26
  # μ„ νƒλœ 메뉴에 λ”°λ₯Έ λ™μž‘ κ΅¬ν˜„
27
- if 'selected_menu' in locals():
 
 
28
  if selected_menu == "Display text":
29
  st.text('Fixed width text')
30
  st.markdown('_Markdown_') # see #*
@@ -36,31 +40,93 @@ if 'selected_menu' in locals():
36
  st.header('My header')
37
  st.subheader('My sub')
38
  st.code('for i in range(8): foo()')
39
-
40
  elif selected_menu == "Display interactive widgets":
41
- if st.button('Hit me'):
42
- st.write('Button clicked!')
43
- data = {'first_col': [1, 2, 3, 4], 'second_col': [10, 20, 30, 40]}
44
- df = pd.DataFrame(data)
45
- # st.data_editor('Edit data', df) # 'st.data_editor' does not exist in Streamlit's current version.
46
- st.checkbox('Check me out')
47
- st.radio('Pick one:', ['nose', 'ear'])
48
- st.selectbox('Select', [1, 2, 3])
49
- st.multiselect('Multiselect', [1, 2, 3])
50
- st.slider('Slide me', min_value=0, max_value=10)
51
- st.select_slider('Slide to select', options=[1, '2'])
52
- st.text_input('Enter some text')
53
- st.number_input('Enter a number')
54
- st.text_area('Area for textual entry')
55
- st.date_input('Date input')
56
- st.time_input('Time entry')
57
- # st.file_uploader('File uploader') # Example does not provide data for 'st.audio', 'st.video', 'st.download_button', etc.
58
- # st.download_button('On the dl', data) # Example does not provide data for this function.
59
- # st.camera_input("δΈ€δΊŒδΈ‰,θŒ„ε­!") # 'st.camera_input' does not exist in Streamlit's current version.
60
- st.color_picker('Pick a color')
61
-
62
- # The rest of the elif blocks for other sub-menus would be similar to above,
63
- # implementing the functionality as per the chosen sub-menu item.
64
-
65
- # Note: Some of the example commands provided do not match with actual Streamlit API functions
66
- # or require context that's not provided, and thus have been commented out or slightly modified.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  # 메뉴 ν•­λͺ©κ³Ό ν•˜μœ„ ν•­λͺ© μ •μ˜
10
  menus = {
11
  "Display": ["Display text", "Display interactive widgets", "Display data", "Display media", "Display code", "Display progress and status"],
12
+ "Data": ["Connect to data sources", "Mutate data", "Placeholders, help, and options"],
13
+ "Control": ["Optimize performance", "Cache global resources", "Deprecated caching"],
14
+ "Layout": ["Columns", "Tabs", "Control flow"],
15
+ "Interactivity": ["Build chat-based apps", "Personalize apps for users"],
16
  }
17
 
18
+ selected_menu = None
19
+
20
  # 각 메뉴에 λŒ€ν•΄ μ‚¬μ΄λ“œλ°”μ— 접이식 메뉴 생성
21
  for menu in menus:
22
  with st.sidebar.expander(menu):
 
26
  break
27
 
28
  # μ„ νƒλœ 메뉴에 λ”°λ₯Έ λ™μž‘ κ΅¬ν˜„
29
+ if selected_menu:
30
+ st.header(f"Selected Menu: {selected_menu}")
31
+
32
  if selected_menu == "Display text":
33
  st.text('Fixed width text')
34
  st.markdown('_Markdown_') # see #*
 
40
  st.header('My header')
41
  st.subheader('My sub')
42
  st.code('for i in range(8): foo()')
43
+
44
  elif selected_menu == "Display interactive widgets":
45
+ # Interactive widgets
46
+ button_clicked = st.button('Hit me')
47
+ checkbox_checked = st.checkbox('Check me out')
48
+ radio_option = st.radio('Pick one:', ['nose', 'ear'])
49
+ selectbox_option = st.selectbox('Select', [1, 2, 3])
50
+ multiselect_options = st.multiselect('Multiselect', [1, 2, 3])
51
+ slider_value = st.slider('Slide me', min_value=0, max_value=10)
52
+ select_slider_option = st.select_slider('Slide to select', options=[1, '2'])
53
+ text_input = st.text_input('Enter some text')
54
+ number_input = st.number_input('Enter a number')
55
+ text_area = st.text_area('Area for textual entry')
56
+ date_input = st.date_input('Date input')
57
+ time_input = st.time_input('Time entry')
58
+ file_uploader = st.file_uploader('File uploader')
59
+ color_picker = st.color_picker('Pick a color')
60
+
61
+ # 주어진 μ½”λ“œ 쀑 μ‹€ν–‰λ˜μ§€ μ•Šκ±°λ‚˜ μ»¨ν…μŠ€νŠΈκ°€ λˆ„λ½λœ 뢀뢄은 주석 μ²˜λ¦¬ν•˜κ±°λ‚˜ μƒλž΅ν–ˆμŠ΅λ‹ˆλ‹€.
62
+ # 예λ₯Ό λ“€μ–΄, `data` λ³€μˆ˜κ°€ μ •μ˜λ˜μ§€ μ•Šμ•˜μœΌλ―€λ‘œ `st.audio(data)`, `st.video(data)` 등은 μ‹€ν–‰ν•  수 μ—†μŠ΅λ‹ˆλ‹€.
63
+ # λ˜ν•œ, `st.data_editor`, `st.camera_input` 등은 Streamlit의 ν˜„μž¬ λ²„μ „μ—μ„œ μ§€μ›ν•˜μ§€ μ•ŠλŠ” κΈ°λŠ₯μž…λ‹ˆλ‹€.
64
+ # 'st.experimental_rerun()'κ³Ό 같은 μ‹€ν—˜μ  κΈ°λŠ₯은 Streamlit의 νŠΉμ • λ²„μ „μ—μ„œλ§Œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
65
+ # 각 κΈ°λŠ₯을 μ‚¬μš©ν•˜κΈ° 전에 Streamlit λ¬Έμ„œλ₯Ό μ°Έκ³ ν•˜μ—¬ ν˜„μž¬ λ²„μ „μ—μ„œ μ§€μ›ν•˜λŠ”μ§€ ν™•μΈν•˜μ„Έμš”.
66
+
67
+ # 기타 κΈ°λŠ₯ κ΅¬ν˜„μ€ μ„ νƒλœ 메뉴에 따라 μœ μ‚¬ν•œ νŒ¨ν„΄μœΌλ‘œ μΆ”κ°€ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
68
+
69
+
70
+ st.write(slider_val)
71
+ st.slider('Pick a number', 0, 100, disabled=True)
72
+ st.dataframe(my_dataframe)
73
+ st.table(data.iloc[0:10])
74
+ st.json({'foo':'bar','fu':'ba'})
75
+ st.metric(label="Temp", value="273 K", delta="1.2 K")
76
+ st.image('./header.png')
77
+ st.audio(data)
78
+ st.video(data)
79
+
80
+ col1, col2 = st.columns(2)
81
+ col1.write('Column 1')
82
+ col2.write('Column 2')
83
+
84
+ # Three columns with different widths
85
+ col1, col2, col3 = st.columns([3,1,1])
86
+ # col1 is wider
87
+
88
+
89
+ # Insert containers separated into tabs:
90
+ >>> tab1, tab2 = st.tabs(["Tab 1", "Tab2"])
91
+ >>> tab1.write("this is tab 1")
92
+ >>> tab2.write("this is tab 2")
93
+
94
+
95
+ # Stop execution immediately:
96
+ st.stop()
97
+ # Rerun script immediately:
98
+ st.experimental_rerun()
99
+
100
+
101
+ st.help(pandas.DataFrame)
102
+ st.get_option(key)
103
+ st.set_option(key, value)
104
+ st.set_page_config(layout='wide')
105
+ st.experimental_show(objects)
106
+ st.experimental_get_query_params()
107
+ st.experimental_set_query_params(**params)
108
+
109
+
110
+
111
+
112
+
113
+ with st.spinner(text='In progress'):
114
+ time.sleep(10)
115
+ st.success('Done')
116
+
117
+ # Show and update progress bar
118
+ bar = st.progress(50)
119
+ time.sleep(10)
120
+ bar.progress(100)
121
+
122
+ st.balloons()
123
+ st.snow()
124
+ st.toast('Mr Stay-Puft')
125
+ st.error('Error message')
126
+ st.warning('Warning message')
127
+ st.info('Info message')
128
+ st.success('Success message')
129
+ st.exception(e)
130
+
131
+
132
+