Spaces:
Build error
Build error
Set consistent keys
Browse filesWith the current script where the component keys change randomly upon each run, the component values are reset immediately after the user interacts the widgets on the page.
To fix it, we should make the component keys consistent across the script runs.
app.py
CHANGED
@@ -29,7 +29,7 @@ st.image(
|
|
29 |
|
30 |
"""
|
31 |
# Try out Theming!
|
32 |
-
Click on the images below to view this app with different themes.
|
33 |
"""
|
34 |
|
35 |
""
|
@@ -90,9 +90,9 @@ def draw_all(
|
|
90 |
st.write(
|
91 |
"""
|
92 |
# Example Widgets
|
93 |
-
|
94 |
-
These widgets don't do anything. But look at all the new colors they got π
|
95 |
-
|
96 |
```python
|
97 |
# First some code.
|
98 |
streamlit = "cool"
|
@@ -102,13 +102,13 @@ def draw_all(
|
|
102 |
"""
|
103 |
)
|
104 |
|
105 |
-
st.checkbox("Is this cool or what?", key=
|
106 |
st.radio(
|
107 |
"How many balloons?",
|
108 |
["1 balloon π", "2 balloons ππ", "3 balloons πππ"],
|
109 |
-
key=
|
110 |
)
|
111 |
-
st.button("π€‘ Click me", key=
|
112 |
|
113 |
# if plot:
|
114 |
# st.write("Oh look, a plot:")
|
@@ -123,18 +123,18 @@ def draw_all(
|
|
123 |
|
124 |
# st.plotly_chart(fig, use_container_width=True)
|
125 |
|
126 |
-
st.file_uploader("You can now upload with style", key=
|
127 |
st.slider(
|
128 |
-
"From 10 to 11, how cool are themes?", min_value=10, max_value=11, key=
|
129 |
)
|
130 |
# st.select_slider("Pick a number", [1, 2, 3], key=key)
|
131 |
-
st.number_input("So many numbers", key=
|
132 |
-
st.text_area("A little writing space for you :)", key=
|
133 |
-
st.text_input("Text input :)", key=
|
134 |
st.selectbox(
|
135 |
"My favorite thing in the world is...",
|
136 |
["Streamlit", "Theming", "Baloooons π "],
|
137 |
-
key=
|
138 |
)
|
139 |
# st.multiselect("Pick a number", [1, 2, 3], key=key)
|
140 |
# st.color_picker("Colors, colors, colors", key=key)
|
|
|
29 |
|
30 |
"""
|
31 |
# Try out Theming!
|
32 |
+
Click on the images below to view this app with different themes.
|
33 |
"""
|
34 |
|
35 |
""
|
|
|
90 |
st.write(
|
91 |
"""
|
92 |
# Example Widgets
|
93 |
+
|
94 |
+
These widgets don't do anything. But look at all the new colors they got π
|
95 |
+
|
96 |
```python
|
97 |
# First some code.
|
98 |
streamlit = "cool"
|
|
|
102 |
"""
|
103 |
)
|
104 |
|
105 |
+
st.checkbox("Is this cool or what?", key=key+":checkbox")
|
106 |
st.radio(
|
107 |
"How many balloons?",
|
108 |
["1 balloon π", "2 balloons ππ", "3 balloons πππ"],
|
109 |
+
key=key+":radio",
|
110 |
)
|
111 |
+
st.button("π€‘ Click me", key=key+":button")
|
112 |
|
113 |
# if plot:
|
114 |
# st.write("Oh look, a plot:")
|
|
|
123 |
|
124 |
# st.plotly_chart(fig, use_container_width=True)
|
125 |
|
126 |
+
st.file_uploader("You can now upload with style", key=key+":file_uploader")
|
127 |
st.slider(
|
128 |
+
"From 10 to 11, how cool are themes?", min_value=10, max_value=11, key=key+":slider"
|
129 |
)
|
130 |
# st.select_slider("Pick a number", [1, 2, 3], key=key)
|
131 |
+
st.number_input("So many numbers", key=key+":number_input")
|
132 |
+
st.text_area("A little writing space for you :)", key=key+":text_area")
|
133 |
+
st.text_input("Text input :)", key=key+":text_input")
|
134 |
st.selectbox(
|
135 |
"My favorite thing in the world is...",
|
136 |
["Streamlit", "Theming", "Baloooons π "],
|
137 |
+
key=key+":selectbox",
|
138 |
)
|
139 |
# st.multiselect("Pick a number", [1, 2, 3], key=key)
|
140 |
# st.color_picker("Colors, colors, colors", key=key)
|