Spaces:
Sleeping
Sleeping
pr16
#16
by Mia2024 - opened
app.py
CHANGED
|
@@ -12,41 +12,43 @@ def delete_callback():
|
|
| 12 |
del st.session_state.gender
|
| 13 |
del st.session_state.profession
|
| 14 |
del st.session_state.hobby
|
|
|
|
| 15 |
|
| 16 |
# # Create two columns
|
| 17 |
# col1, col2 = st.columns(2)
|
| 18 |
|
| 19 |
# # Place a form in each column
|
| 20 |
# with col1:
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
# with col2:
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
| 50 |
st.write_stream(stream_data)
|
| 51 |
|
| 52 |
|
|
|
|
| 12 |
del st.session_state.gender
|
| 13 |
del st.session_state.profession
|
| 14 |
del st.session_state.hobby
|
| 15 |
+
st.experimental_rerun()
|
| 16 |
|
| 17 |
# # Create two columns
|
| 18 |
# col1, col2 = st.columns(2)
|
| 19 |
|
| 20 |
# # Place a form in each column
|
| 21 |
# with col1:
|
| 22 |
+
with st.form("my_input"):
|
| 23 |
+
st.write("Input")
|
| 24 |
+
# product
|
| 25 |
+
product=st.text_input("product", key="product")
|
| 26 |
+
# gender
|
| 27 |
+
gender=st.radio("gender", ["male", "female"], key="gender")
|
| 28 |
+
# profession
|
| 29 |
+
profession=st.text_input("profession", key="profession")
|
| 30 |
+
# hobby
|
| 31 |
+
hobby=st.text_input("hobby", key="hobby")
|
| 32 |
+
# Every form must have a submit button.
|
| 33 |
+
btn1, btn2=st.columns(2)
|
| 34 |
+
with btn1:
|
| 35 |
+
# submitted = st.form_submit_button(label='Submit', on_click=submit_callback)
|
| 36 |
+
submitted = st.form_submit_button(label='Submit')
|
| 37 |
+
with btn2:
|
| 38 |
+
clear = st.form_submit_button(label='Clear', on_click=delete_callback)
|
| 39 |
|
| 40 |
# with col2:
|
| 41 |
+
_LOREM_IPSUM = "product" + st.session_state.product + "\n"
|
| 42 |
+
+ "gender" + st.session_state.gender + "\n"
|
| 43 |
+
+ "profession" + st.session_state.profession + "\n"
|
| 44 |
+
+ "hobby" + st.session_state.hobby +"\n"
|
| 45 |
+
|
| 46 |
+
def stream_data():
|
| 47 |
+
for word in _LOREM_IPSUM.split(" "):
|
| 48 |
+
yield word + " "
|
| 49 |
+
time.sleep(0.02)
|
| 50 |
+
|
| 51 |
+
if st.button("Stream data"):
|
| 52 |
st.write_stream(stream_data)
|
| 53 |
|
| 54 |
|