Spaces:
Sleeping
Sleeping
pr9 (#9)
Browse files- modify7 (06713d130eae05402693d20b6eaf26daa8e9bc6d)
app.py
CHANGED
@@ -1,54 +1,101 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import time
|
3 |
|
4 |
-
with st.form("my_input"):
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
|
26 |
|
27 |
-
with st.form("my_output"):
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
_LOREM_IPSUM = """
|
38 |
-
Lorem ipsum dolor sit amet, **consectetur adipiscing** elit, sed do eiusmod tempor
|
39 |
-
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
40 |
-
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
41 |
-
"""
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
yield word + " "
|
46 |
-
time.sleep(0.02)
|
47 |
|
48 |
-
for word in _LOREM_IPSUM.split(" "):
|
49 |
-
yield word + " "
|
50 |
-
time.sleep(0.02)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
|
54 |
-
st.write_stream(stream_data)
|
|
|
1 |
+
# import streamlit as st
|
2 |
+
# import time
|
3 |
|
4 |
+
# with st.form("my_input"):
|
5 |
+
# st.write("Input")
|
6 |
+
# # product
|
7 |
+
# product=st.text_input("product")
|
8 |
+
# # gender
|
9 |
+
# gender=st.radio("gender", ["male", "female"])
|
10 |
+
# # profession
|
11 |
+
# profession=st.text_input("profession")
|
12 |
+
# # hobby
|
13 |
+
# hobby=st.text_input("hobby")
|
14 |
+
|
15 |
+
# # Every form must have a submit button.
|
16 |
+
# col1, col2=st.columns(2)
|
17 |
+
|
18 |
+
# # Place a button in each column
|
19 |
+
# with col1:
|
20 |
+
# submitted = st.form_submit_button("Submit")
|
21 |
+
|
22 |
+
# with col2:
|
23 |
+
# clear = st.form_submit_button("Clear")
|
24 |
|
25 |
|
26 |
|
27 |
+
# with st.form("my_output"):
|
28 |
+
# if submitted:
|
29 |
+
# st.write("product", product)
|
30 |
+
# st.write("gender", gender)
|
31 |
+
# st.write("profession", profession)
|
32 |
+
# st.write("hobby", hobby)
|
33 |
+
# # Clear the user inputs
|
34 |
+
# if clear:
|
35 |
+
# st.experimental_rerun()
|
36 |
+
|
37 |
+
# _LOREM_IPSUM = """
|
38 |
+
# Lorem ipsum dolor sit amet, **consectetur adipiscing** elit, sed do eiusmod tempor
|
39 |
+
# incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
40 |
+
# nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
41 |
+
# """
|
42 |
+
|
43 |
+
# def stream_data():
|
44 |
+
# for word in _LOREM_IPSUM.split(" "):
|
45 |
+
# yield word + " "
|
46 |
+
# time.sleep(0.02)
|
47 |
+
|
48 |
+
# for word in _LOREM_IPSUM.split(" "):
|
49 |
+
# yield word + " "
|
50 |
+
# time.sleep(0.02)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
+
# if st.button("Stream data"):
|
54 |
+
# st.write_stream(stream_data)
|
|
|
|
|
55 |
|
|
|
|
|
|
|
56 |
|
57 |
+
import streamlit as st
|
58 |
+
import SessionState
|
59 |
+
|
60 |
+
# Initialize session state
|
61 |
+
session_state = SessionState.get(product="", gender="", profession="", hobby="")
|
62 |
+
|
63 |
+
# Create a form for user inputs
|
64 |
+
with st.form("my_input"):
|
65 |
+
st.write("Input")
|
66 |
+
# product
|
67 |
+
product = st.text_input("product", value=session_state.product)
|
68 |
+
# gender
|
69 |
+
gender = st.radio("gender", ["male", "female"], index=["male", "female"].index(session_state.gender) if session_state.gender else 0)
|
70 |
+
# profession
|
71 |
+
profession = st.text_input("profession", value=session_state.profession)
|
72 |
+
# hobby
|
73 |
+
hobby = st.text_input("hobby", value=session_state.hobby)
|
74 |
+
|
75 |
+
# Every form must have a submit button.
|
76 |
+
submitted = st.form_submit_button("Submit")
|
77 |
+
clear = st.form_submit_button("Clear")
|
78 |
+
|
79 |
+
# Display the user inputs
|
80 |
+
with st.form("my_output"):
|
81 |
+
if submitted and not clear:
|
82 |
+
# Save inputs to session state
|
83 |
+
session_state.product = product
|
84 |
+
session_state.gender = gender
|
85 |
+
session_state.profession = profession
|
86 |
+
session_state.hobby = hobby
|
87 |
+
|
88 |
+
st.write("product", product)
|
89 |
+
st.write("gender", gender)
|
90 |
+
st.write("profession", profession)
|
91 |
+
st.write("hobby", hobby)
|
92 |
+
|
93 |
+
# Clear the user inputs
|
94 |
+
if clear:
|
95 |
+
# Clear session state
|
96 |
+
session_state.product = ""
|
97 |
+
session_state.gender = ""
|
98 |
+
session_state.profession = ""
|
99 |
+
session_state.hobby = ""
|
100 |
|
101 |
+
st.experimental_rerun()
|
|