Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -14,10 +14,15 @@ from st_click_detector import click_detector
|
|
14 |
# callback to update query param on selectbox change
|
15 |
def update_params():
|
16 |
print("update1")
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# check if here for the first time then set the query
|
23 |
if 'query' not in st.session_state:
|
@@ -34,9 +39,6 @@ except: # catch exception and set query param to predefined value
|
|
34 |
print("Error cant set after init")
|
35 |
#if 'query' not in st.session_state:
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
# radio button persistance - plan is to hydrate when selected and change url along with textbox and search
|
41 |
options = ["ai", "nlp", "iot", "vr", "genomics", "graph", "cognitive"]
|
42 |
query_params = st.experimental_get_query_params()
|
@@ -47,9 +49,8 @@ if query_params:
|
|
47 |
ix = options.index(q0)
|
48 |
except ValueError:
|
49 |
pass
|
50 |
-
|
51 |
-
|
52 |
-
)
|
53 |
|
54 |
# Text Input, check the query params set the text input to query value if in session
|
55 |
try:
|
@@ -57,13 +58,11 @@ try:
|
|
57 |
query_option = query_params['query'][0] #throws an exception when visiting http://host:port
|
58 |
option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option))
|
59 |
except: # catch exception and set query param to predefined value
|
60 |
-
st.experimental_set_query_params(query="Genomics") # set default
|
61 |
query_params = st.experimental_get_query_params()
|
62 |
query_option = query_params['query'][0]
|
63 |
|
64 |
-
st.experimental_set_query_params(option=selected_option)
|
65 |
-
|
66 |
-
|
67 |
|
68 |
|
69 |
# What impresses me about these two beautiful new streamlit persist prims is that one called the singleton can share memory across sessions (think all users yo)
|
14 |
# callback to update query param on selectbox change
|
15 |
def update_params():
|
16 |
print("update1")
|
17 |
+
try:
|
18 |
+
st.experimental_set_query_params(option=st.session_state.query)
|
19 |
+
except ValueError:
|
20 |
+
pass
|
21 |
+
|
22 |
+
# RADIO BUTTON SET PERSIST
|
23 |
+
selected_option = st.radio(
|
24 |
+
"Param", options, index=ix, key="query", on_change=update_params
|
25 |
+
)
|
26 |
|
27 |
# check if here for the first time then set the query
|
28 |
if 'query' not in st.session_state:
|
39 |
print("Error cant set after init")
|
40 |
#if 'query' not in st.session_state:
|
41 |
|
|
|
|
|
|
|
42 |
# radio button persistance - plan is to hydrate when selected and change url along with textbox and search
|
43 |
options = ["ai", "nlp", "iot", "vr", "genomics", "graph", "cognitive"]
|
44 |
query_params = st.experimental_get_query_params()
|
49 |
ix = options.index(q0)
|
50 |
except ValueError:
|
51 |
pass
|
52 |
+
|
53 |
+
|
|
|
54 |
|
55 |
# Text Input, check the query params set the text input to query value if in session
|
56 |
try:
|
58 |
query_option = query_params['query'][0] #throws an exception when visiting http://host:port
|
59 |
option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option))
|
60 |
except: # catch exception and set query param to predefined value
|
61 |
+
#st.experimental_set_query_params(query="Genomics") # set default
|
62 |
query_params = st.experimental_get_query_params()
|
63 |
query_option = query_params['query'][0]
|
64 |
|
65 |
+
#st.experimental_set_query_params(option=selected_option)
|
|
|
|
|
66 |
|
67 |
|
68 |
# What impresses me about these two beautiful new streamlit persist prims is that one called the singleton can share memory across sessions (think all users yo)
|