Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Function to add a new option to the radio list
|
| 4 |
+
def add_option(option):
|
| 5 |
+
if option and option not in st.session_state.radio_options:
|
| 6 |
+
st.session_state.radio_options.append(option)
|
| 7 |
+
|
| 8 |
+
# Initialize the session state for radio options if not already done
|
| 9 |
+
if 'radio_options' not in st.session_state:
|
| 10 |
+
st.session_state.radio_options = []
|
| 11 |
+
|
| 12 |
+
# Text input for new option
|
| 13 |
+
new_option = st.text_input("Enter a new radio option")
|
| 14 |
+
|
| 15 |
+
# Button to add the new option
|
| 16 |
+
if st.button("Add Option"):
|
| 17 |
+
add_option(new_option)
|
| 18 |
+
|
| 19 |
+
# Display the radio buttons
|
| 20 |
+
st.radio("Options List", st.session_state.radio_options)
|