File size: 3,575 Bytes
a16ad43
 
8caf9d5
c9e23c5
a16ad43
 
 
 
 
c9e23c5
 
 
 
 
 
bf00b5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6aac964
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a2054cf
 
6aac964
 
a2054cf
 
a16ad43
 
 
 
6aac964
a16ad43
 
6aac964
a16ad43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import time

def submit_callback():
    st.write(st.session_state.product)
    st.write(st.session_state.gender) 
    st.write(st.session_state.profession) 
    st.write(st.session_state.hobby)

def delete_callback():
    del st.session_state.product
    del st.session_state.gender
    del st.session_state.profession
    del st.session_state.hobby

# Create two columns
col1, col2 = st.columns(2)

# Place a form in each column
with col1:
    with st.form("my_input"):
        st.write("Input")
        # product
        product=st.text_input("product", key="product")
        # gender
        gender=st.radio("gender", ["male", "female"], key="gender")
        # profession
        profession=st.text_input("profession", key="profession")
        # hobby
        hobby=st.text_input("hobby", key="hobby")
        # Every form must have a submit button.
        btn1, btn2=st.columns(2)
        with btn1:
                submitted = st.form_submit_button(label='Submit', on_click=submit_callback)
        with btn2:
                clear = st.form_submit_button(label='Clear', on_click=delete_callback) 

with col2:
    with st.form("my_output"):
        st.write("product", st.session_state.product)
        st.write("gender", st.session_state.gender)
        st.write("profession", st.session_state.profession)
        st.write("hobby", st.session_state.hobby)





    

# _LOREM_IPSUM = """
# Lorem ipsum dolor sit amet, **consectetur adipiscing** elit, sed do eiusmod tempor
# incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
# nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
# """

# def stream_data():
#     for word in _LOREM_IPSUM.split(" "):
#         yield word + " "
#         time.sleep(0.02)

#     for word in _LOREM_IPSUM.split(" "):
#         yield word + " "
#         time.sleep(0.02)


# if st.button("Stream data"):
#     st.write_stream(stream_data)


# import streamlit as st
# import SessionState
# from streamlit.server.server import Server
# import streamlit.report_thread as ReportThread

# # Initialize session state
# session_state = SessionState.get(product="", gender="", profession="", hobby="")

# # Create a form for user inputs
# with st.form("my_input"):
#     st.write("Input")
#     # product
#     product = st.text_input("product", value=session_state.product)
#     # gender
#     gender = st.radio("gender", ["male", "female"], index=["male", "female"].index(session_state.gender) if session_state.gender else 0)
#     # profession
#     profession = st.text_input("profession", value=session_state.profession)
#     # hobby
#     hobby = st.text_input("hobby", value=session_state.hobby)

#     # Every form must have a submit button.
#     submitted = st.form_submit_button("Submit")
#     clear = st.form_submit_button("Clear")

# # Display the user inputs
# with st.form("my_output"):
#     if submitted and not clear:
#         # Save inputs to session state
#         session_state.product = product
#         session_state.gender = gender
#         session_state.profession = profession
#         session_state.hobby = hobby

#         st.write("product", product)
#         st.write("gender", gender)
#         st.write("profession", profession)
#         st.write("hobby", hobby)

#     # Clear the user inputs
#     if clear:
#         # Clear session state
#         session_state.product = ""
#         session_state.gender = ""
#         session_state.profession = ""
#         session_state.hobby = ""

#         st.experimental_rerun()