I’d like to execute a function that opens a dialog box when we click on a metric component. For instance, if a metric says we have 5 open items, I’d like to click on it to open a dialog box to display a table with the details of those records.
# If the condition (5 open items) open a button popover displaying the talbe
if your_condition:
with st.popover("Open table"):
st.write("### Open Items")
st.table(open_items)
list = ['Temperature', 'Wind', 'noideawhatelse']
value = ["70 °F", "150m.s", "3.14"]
delta = ["1.2 °F", "-10 ms", '42']
@st.experimental_dialog("Cast your vote")
def vote(item):
st.write(f"Why is {item} your favorite?")
reason = st.text_input("Because...")
if st.button("Submit"):
st.session_state.vote = {"item": item, "reason": reason}
st.rerun()
for i, col in enumerate(st.columns(3)):
col.metric(label=" ", value=value[i], delta=delta[i], label_visibility="hidden")
if col.button(list[i]):
vote("A")