统一使用start.sh启动
两个demo页面
This commit is contained in:
31
pages/test2_input-output.py
Normal file
31
pages/test2_input-output.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import random
|
||||
|
||||
import streamlit as st
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
if "counter" not in st.session_state:
|
||||
st.session_state.counter = 0
|
||||
|
||||
st.session_state.counter += 1
|
||||
|
||||
st.header(f"This page has run {st.session_state.counter} times.")
|
||||
st.button("Run it again")
|
||||
|
||||
if "df" not in st.session_state:
|
||||
st.session_state.df = pd.DataFrame(np.random.randn(20, 2), columns=["x", "y"])
|
||||
if "color" not in st.session_state:
|
||||
st.session_state.color = "#FF0000"
|
||||
|
||||
|
||||
def generate_random_color():
|
||||
rand_color = "#{:06x}".format(random.randint(0, 0xFFFFFF))
|
||||
st.session_state.color = rand_color.upper()
|
||||
|
||||
|
||||
st.header("Choose a datapoint color")
|
||||
st.color_picker("Color", "#FF0000", key="color")
|
||||
st.button("random color", key="random_color", on_click=generate_random_color)
|
||||
st.divider()
|
||||
|
||||
st.scatter_chart(st.session_state.df, x="x", y="y", color=st.session_state.color)
|
||||
Reference in New Issue
Block a user