Hi. I’m currently building my streamlit app locally and I’m having trouble getting the submit button to work. Ideally, when given a list of elements, I want the app to print out an accompanying description & picture for each element. After all of that has been printed out for each element, I want to use a radio button to allow the user to choose their ‘favorite from the selections’ & press the ‘Create vacation’ button to move on to the next step of the code. But, whenever it gets to this section of the code, whenever you manipulate the radio button at all, the entire section disappears. I’ve tried all variation of if button and they all produce the same results. Any help?
#Function use to similuate a suggestions page, based on gemini suggestions
def suggestionsPage(self, locations):
st.header('Suggestion Page')
st.subheader("Based on your suggestions we think you'll enjoy the following places. Look at the suggestions shown and choose your favorite ")
#Create components to showcase locations. Component includes city name, descripition & images
cities = list(locations.split(';'))
col1, col2 = st.columns([0.6, 0.4])
for city in cities:
with col1:
st.subheader(city)
cityDescription = textModel.generate_content('Come up with 2-3 sentences, in paragraph form to describe ' + city)
if cityDescription:
st.write(cityDescription.text)
else:
st.warning("Error generating content")
with col2:
images = imageModel.generate_images('Pull an image from the following location'+ city)
if images:
images[0].save(location="traveling.jpg")
st.image("traveling.jpg", width=250)
#Button reacts prematurely or erases the entire page
chosenCity = st.radio("Choose your favorite so we can build your dream vacation:", options=cities)
submitBtn = st.button("Create Vacation")
if submitBtn:
self.planTrip(chosenCity)