Spaces:
Running
Running
xhluca
commited on
Commit
•
cfdb2f8
1
Parent(s):
323610b
Fix query param
Browse files
app.py
CHANGED
@@ -216,33 +216,53 @@ def run():
|
|
216 |
# mode = st.sidebar.radio("Mode", ["Overview"])
|
217 |
demonstration_dir = "./demonstrations"
|
218 |
|
219 |
-
# params = st.experimental_get_query_params()
|
220 |
-
params = st.query_params
|
221 |
-
print(params)
|
222 |
|
223 |
-
# list demonstrations/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
demo_names = os.listdir(demonstration_dir)
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
recording_name = params["recording"][0]
|
229 |
-
else:
|
230 |
-
recording_name = params["recording"]
|
231 |
|
232 |
-
|
233 |
-
|
|
|
234 |
|
235 |
-
recording_name = st.
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
|
|
239 |
)
|
240 |
|
241 |
-
if recording_name != params.get("recording", [None])[0]:
|
242 |
-
# st.experimental_set_query_params(recording=recording_name)
|
243 |
-
# use st.query_params as a dict instead
|
244 |
-
st.query_params['recording'] = recording_name
|
245 |
-
|
246 |
with st.sidebar:
|
247 |
# Want a dropdown
|
248 |
st.selectbox(
|
|
|
216 |
# mode = st.sidebar.radio("Mode", ["Overview"])
|
217 |
demonstration_dir = "./demonstrations"
|
218 |
|
219 |
+
# # params = st.experimental_get_query_params()
|
220 |
+
# params = st.query_params
|
221 |
+
# print(params)
|
222 |
|
223 |
+
# # list demonstrations/
|
224 |
+
# demo_names = os.listdir(demonstration_dir)
|
225 |
+
|
226 |
+
# if params.get("recording"):
|
227 |
+
# if isinstance(params["recording"], list):
|
228 |
+
# recording_name = params["recording"][0]
|
229 |
+
# else:
|
230 |
+
# recording_name = params["recording"]
|
231 |
+
|
232 |
+
# else:
|
233 |
+
# recording_name = demo_names[0]
|
234 |
+
|
235 |
+
# recording_name = st.sidebar.selectbox(
|
236 |
+
# "Recordings",
|
237 |
+
# demo_names,
|
238 |
+
# index=demo_names.index(recording_name),
|
239 |
+
# )
|
240 |
+
|
241 |
+
# if recording_name != params.get("recording", [None])[0]:
|
242 |
+
# # st.experimental_set_query_params(recording=recording_name)
|
243 |
+
# # use st.query_params as a dict instead
|
244 |
+
# st.query_params['recording'] = recording_name
|
245 |
+
|
246 |
+
|
247 |
demo_names = os.listdir(demonstration_dir)
|
248 |
|
249 |
+
def update_recording_name():
|
250 |
+
st.query_params["recording"] = st.session_state.get("recording_name")
|
|
|
|
|
|
|
251 |
|
252 |
+
# For initial run, set the query parameter to the selected recording
|
253 |
+
if not st.query_params.get("recording"):
|
254 |
+
update_recording_name()
|
255 |
|
256 |
+
recording_name = st.query_params.get("recording")
|
257 |
+
if recording_name not in demo_names:
|
258 |
+
st.error(f"Recording `{recording_name}` not found. Please select another recording.")
|
259 |
+
st.stop()
|
260 |
+
|
261 |
+
recording_idx = demo_names.index(recording_name)
|
262 |
+
st.sidebar.selectbox(
|
263 |
+
"Recordings", demo_names, on_change=update_recording_name, key="recording_name", index=recording_idx
|
264 |
)
|
265 |
|
|
|
|
|
|
|
|
|
|
|
266 |
with st.sidebar:
|
267 |
# Want a dropdown
|
268 |
st.selectbox(
|