an app that allows me to display a button, move to the next step and display the next set
To upload files, please first save the app
from enum import Enum
import streamlit as st
class Step(Enum):
INITIAL = 1
PLACEHOLDER_SELECTION = 2
PROCESSING = 3
@classmethod
def next_value(cls, current_value):
next_value = (current_value.value % len(cls)) + 1
return Step(next_value)
if "step" not in st.session_state:
st.session_state.step = Step.INITIAL
cols = st.columns([1, 1, 1, 1, 1])
def handle_placeholder_click(message=None):
if st.session_state.step == Step.PROCESSING:
st.session_state.step = Step.INITIAL
else:
st.session_state.step = Step.next_value(st.session_state.step)
st.write(f"Message: {message}")
if st.session_state.step.value == Step.INITIAL.value:
st.button(
"Click here to display placeholder messages",
on_click=handle_placeholder_click,
args=("Display placeholders",),
)
elif st.session_state.step.value == Step.PLACEHOLDER_SELECTION.value:
with cols[1]:
st.button(
"Placeholder 1", on_click=handle_placeholder_click, args=("Placeholder 1",)
)
with cols[2]:
st.button(
"Placeholder 2", on_click=handle_placeholder_click, args=("Placeholder 2",)
)
with cols[3]:
st.button(
"Placeholder 3", on_click=handle_placeholder_click, args=("Placeholder 3",)
)
else:
st.write("The message has been sent and is being processed.")
st.button("RESET", on_click=handle_placeholder_click, args=("RESET BUTTON",))
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?