having trouble adding a “Yes”, “No” button inside of my “End” button, so that the user is sure they are reading to end data collection, and it was not just a faulty touch. how would I go about this?
import streamlit as st
# Streamlit app
st.markdown("<h1 style='text-align: center; color: #001e69;'>Welcome to the LETREP25 Project!</h1>", unsafe_allow_html=True)
st.subheader("Please login with your username and password below")
st.markdown("")
# Function to simulate authentication
def authenticate(username, password):
return username == "letrep" and password == "letrep123"
# Create input fields for username and password
username = st.text_input("Username")
password = st.text_input("Password", type="password")
# Initialize session state for logged_in, dashboard_accessed, and data_collection_active
if 'logged_in' not in st.session_state:
st.session_state.logged_in = False
if 'dashboard_accessed' not in st.session_state:
st.session_state.dashboard_accessed = False
if 'data_collection_active' not in st.session_state:
st.session_state.data_collection_active = False
# Create a button to trigger the authentication process
if st.button("Login"):
if authenticate(username, password):
st.session_state.logged_in = True
st.success("Logged in successfully!")
else:
st.session_state.logged_in = False
st.error("Invalid username or password")
# Check the session state for login status
if st.session_state.logged_in:
st.write("Welcome, you are logged in!")
st.subheader("")
st.header("Instructions")
st.subheader("...Once human interface is chosen, and instructions are clear on how to use device, enter instructions here...")
st.header("")
st.subheader("Please select start if you are ready to begin data collection")
if st.button("Start"):
st.session_state.dashboard_accessed = True
st.subheader("Are you sure you want data collection to begin?")
if st.session_state.dashboard_accessed:
if st.button("Yes"):
st.session_state.data_collection_active = True
st.write("Data collection has begun")
st.subheader("Please do not remove sensors until you are done with data collection")
st.balloons()
st.subheader("")
st.subheader("Click here to end data collection")
# add an "end" button to stop data collection
if st.session_state.data_collection_active:
if st.button("End"):
st.session_state.data_collection_active = False
st.write("Data collection has ended")
st.balloons()
# add a "yes", "no" button to be sure the user is sure that they want to end data collection
if st.button("No"):
st.write("Data collection will not begin")
else:
st.write("Please enter your credentials.")