Spaces:
Sleeping
Sleeping
File size: 4,471 Bytes
cead143 89b2b74 79d2b6a 6e8c858 89b2b74 a3b9bb0 6e8c858 a3b9bb0 6e8c858 89b2b74 6e8c858 89b2b74 a3b9bb0 89b2b74 a3b9bb0 89b2b74 a3b9bb0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
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"],
"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:
st.header(f"Selected Menu: {selected_menu}")
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":
# 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')
# μ£Όμ΄μ§ μ½λ μ€ μ€νλμ§ μκ±°λ 컨ν
μ€νΈκ° λλ½λ λΆλΆμ μ£Όμ μ²λ¦¬νκ±°λ μλ΅νμ΅λλ€.
# μλ₯Ό λ€μ΄, `data` λ³μκ° μ μλμ§ μμμΌλ―λ‘ `st.audio(data)`, `st.video(data)` λ±μ μ€νν μ μμ΅λλ€.
# λν, `st.data_editor`, `st.camera_input` λ±μ Streamlitμ νμ¬ λ²μ μμ μ§μνμ§ μλ κΈ°λ₯μ
λλ€.
# 'st.experimental_rerun()'κ³Ό κ°μ μ€νμ κΈ°λ₯μ Streamlitμ νΉμ λ²μ μμλ§ μ¬μ©ν μ μμ΅λλ€.
# κ° κΈ°λ₯μ μ¬μ©νκΈ° μ μ Streamlit λ¬Έμλ₯Ό μ°Έκ³ νμ¬ νμ¬ λ²μ μμ μ§μνλμ§ νμΈνμΈμ.
# κΈ°ν κΈ°λ₯ ꡬνμ μ νλ λ©λ΄μ λ°λΌ μ μ¬ν ν¨ν΄μΌλ‘ μΆκ°ν μ μμ΅λλ€.
st.write(slider_val)
st.slider('Pick a number', 0, 100, disabled=True)
st.dataframe(my_dataframe)
st.table(data.iloc[0:10])
st.json({'foo':'bar','fu':'ba'})
st.metric(label="Temp", value="273 K", delta="1.2 K")
st.image('./header.png')
st.audio(data)
st.video(data)
col1, col2 = st.columns(2)
col1.write('Column 1')
col2.write('Column 2')
# Three columns with different widths
col1, col2, col3 = st.columns([3,1,1])
# col1 is wider
# Insert containers separated into tabs:
>>> tab1, tab2 = st.tabs(["Tab 1", "Tab2"])
>>> tab1.write("this is tab 1")
>>> tab2.write("this is tab 2")
# Stop execution immediately:
st.stop()
# Rerun script immediately:
st.experimental_rerun()
st.help(pandas.DataFrame)
st.get_option(key)
st.set_option(key, value)
st.set_page_config(layout='wide')
st.experimental_show(objects)
st.experimental_get_query_params()
st.experimental_set_query_params(**params)
with st.spinner(text='In progress'):
time.sleep(10)
st.success('Done')
# Show and update progress bar
bar = st.progress(50)
time.sleep(10)
bar.progress(100)
st.balloons()
st.snow()
st.toast('Mr Stay-Puft')
st.error('Error message')
st.warning('Warning message')
st.info('Info message')
st.success('Success message')
st.exception(e)
|