123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- from datetime import datetime
- from numpy import empty, not_equal
- import streamlit as st
- import time
- import pandas as pd
- import numpy as np
- import streamlit.components.v1 as components
- about_message = '''
- # About
- ## testing!
- :smile:
- '''
- st.set_page_config(
- page_title="Streamlit example",
- page_icon="./icon/android-chrome-192x192.png",
- layout="wide",
- initial_sidebar_state="collapsed",
- menu_items={
- 'Get Help': 'https://www.baidu.com/',
- 'Report a bug': None,
- 'About': about_message
- }
- )
- st.image("./icon/android-chrome-192x192.png")
- def t1():
- st.text("t1-ing!")
- '''# 组件'''
- a = st.checkbox('test_checkbox', value=False, key=None, help="testing", on_change=None, args=None, kwargs=None)
- b = st.button(label="button", key=None, help="testing!", on_click=None)
- c = st.download_button(label="download_button", data='testttt', file_name='test_.md', help='testing!', on_click=None)
- d = st.radio(label="What's your favorite movie genre",options=('Comedy', 'Drama', 'Documentary'),index=2, help='testing!')
- e = st.selectbox('slectbox',('Comedy', 'Drama', 'Documentary'),index=2, help='testing!')
- f = st.multiselect('multiselect',('Comedy', 'Drama', 'Documentary'), default=['Drama'], help='testing!')
- g = st.slider(label="slider", min_value=-10, max_value=10, value=-2, step=1, help="testing!", on_change=t1)
- h = st.select_slider(label='select_slider', options=[1,'test2',3], value=3, help="testing!")
- i = st.text_input(label='text_input', max_chars=30, value='test1', help='testing!', placeholder='请输入')
- j = st.number_input("number_input", min_value=-10, max_value=10, value=2, step=2, help="testing")
-
- k = st.text_area("text_area", value="test1",max_chars=60, help="testing!", placeholder="请输入")
- dt1 = datetime.today()
- dt2 = datetime.today()
- l = st.date_input(label="date_input", value=(dt1,dt2))
- m = st.time_input("time_input", value=None, help="testing!")
- n = st.file_uploader(label='file_uploader', accept_multiple_files=True, help="testing!")
- o = st.color_picker('color_picker', '#00f900')
- p = st.image(image=['https://i.bmp.ovh/imgs/2021/10/3fd6c4674301c708.jpg',"./data/testimage.jpg"])
- q = st.audio("http://music.163.com/song/media/outer/url?id=1901371647.mp3")
- components.iframe(src="//player.bilibili.com/player.html?aid=376524564&bvid=BV1wo4y1X7Tk&cid=365010431&page=1", width=1080, height=720, scrolling=False)
- r = st.video("./data/testybb.mp4")
- add_selectbox = st.sidebar.selectbox(
- label="How would you like to be contacted?",
- options=("Email", "Home phone", "Mobile phone"),
- key="t1"
- )
- add_selectbox2 = st.sidebar.selectbox(
- label="How would you like to be contacted?",
- options=("Email", "Home phone", "Mobile phone"),
- key="t2"
- )
- col1, col2, col3 = st.columns(3)
- with col1:
- st.header("A cat")
- st.image("https://static.streamlit.io/examples/cat.jpg")
- with col2:
- st.header("A dog")
- st.image("https://static.streamlit.io/examples/dog.jpg")
- with col3:
- st.header("An owl")
- st.image("https://static.streamlit.io/examples/owl.jpg")
- with st.expander(label="expander", expanded=False):
- st.write("tesing")
- with st.container():
- st.write("container")
- container = st.container()
- container.write("containertext1")
- st.write("not container")
- container.write("containertext2")
- st.error('error!💀')
- st.warning("warning! :warning:")
- st.info('message ℹ')
- st.success("success 🎉")
- e = RuntimeError("an exception")
- st.exception(e)
- name = st.text_input('Name')
- if not name:
- st.warning('Please input a name.')
- st.stop()
- st.success('Thank you for inputting a name.')
-
- form = st.form(key="my_form2")
- form.slider("Inside the form")
- form.form_submit_button("Submit")
- with st.echo("below"):
- st.write('This code will be printed')
- st.help(st.help)
- df1 = pd.DataFrame(
- np.random.randn(1, 5),
- columns=('col %d' % i for i in range(5)))
- my_table = st.table(df1)
- df2 = pd.DataFrame(
- np.random.randn(2, 5),
- columns=('col %d' % i for i in range(5)))
- my_table.add_rows(df2)
- st.markdown(":smile:😁")
- st.text("😁")
- st.text(type(r))
|