gpt-3.5-turbo-0125· OpenAI
WildChat-4.8M (AI2)
how to store the outputs in streamlit for multiple buttons
- User
how to store the outputs in streamlit for multiple buttons
- Assistant
To store the outputs in Streamlit for multiple buttons, you can use Streamlit's st.cache function or create a dictionary to store the outputs. Here is an example of how you can achieve this:
pythonimport streamlit as st # Create a dictionary to store the outputs outputs = {} # Define functions for each button def button1_func(): outputs['output1'] = "Output for Button 1" st.write("Output for Button 1 stored successfully.") def button2_func(): outputs['output2'] = "Output for Button 2" st.write("Output for Button 2 stored successfully.") # Create buttons to trigger the functions if st.button('Button 1'): button1_func() if st.button('Button 2'): button2_func() # Display the stored outputs if 'output1' in outputs: st.write("Output 1:", outputs['output1']) if 'output2' in outputs: st.write("Output 2:", outputs['output2'])