Hi,
Iโm running on Windows 10 & Anaconda Python 3.7
Iโm able to launch the app and it works successfully until the last selectbox where the app refreshes when I pick a value from the selectbox or click on any of the last two buttons. Iโm very new to streamlit and would appreciate any help/guidance.
import streamlit as st
import pandas as pd
import random
def main():
st.title("Testing Tool")
#Sample Names
names = ['Dan','Joe','John','Bob','Scott','Sam']
# Customer SelectBox
person_name = st.selectbox("Select Name", names)
st.write("You selected this:", person_name)
# Product SelectBox
products = ['Mars','Snickers','Twix','Kit-kat', 'M&Ms', 'Toblerone','Skittles']
product = st.selectbox("Select Product", products)
st.write("You selected this Product:", product)
# Generate Recommendations
# Slider
number_of_recs = st.slider("Number of Recommendations",1,10)
recs = ''
if st.button('Click Here'):
choices_ = ['X','Y','S','A','Z','D']
recs = random.choices(choices_, k=number_of_recs)
#st.success(recs)
for p, n in enumerate(recs):
st.write(f"Rec {p+1}:", n)
selection = st.selectbox('Select One:', recs, format_func=lambda x: 'Select One' if x == '' else x)
st.write("You selected:", selection)
if selection:
if st.button(f'See Past Purchases for {selection}'):
st.write('Showing History')
if st.button(f'See Reviews for {selection}'):
st.write('Showing Reviews')
else:
st.write('Click To Generate Recommendations')
main()