|
import streamlit as st |
|
import json |
|
|
|
def app(): |
|
st.header("Career Preferences") |
|
|
|
preferences_sections = [ |
|
"Size of Organization", |
|
"Type of Organization", |
|
"Industry", |
|
"Department", |
|
"Function" |
|
] |
|
|
|
preferences_questions = ["What I think I want", "What I know I don’t want"] |
|
|
|
|
|
if 'preferences_sets' not in st.session_state: |
|
st.session_state.preferences_sets = [{}] |
|
|
|
|
|
def add_another_set(): |
|
st.session_state.preferences_sets.append({}) |
|
|
|
|
|
for i, preferences_set in enumerate(st.session_state.preferences_sets): |
|
with st.expander(f"Preferences Set {i + 1}", expanded=True): |
|
for section in preferences_sections: |
|
st.subheader(section) |
|
for question in preferences_questions: |
|
key = f"{section}_{question}_{i}" |
|
st.session_state.preferences_sets[i][f"{section}: {question}"] = st.text_area( |
|
label=question, |
|
key=key, |
|
value=preferences_set.get(f"{section}: {question}", "") |
|
) |
|
|
|
st.button("Add More", on_click=add_another_set) |
|
|
|
if st.button('Save Preferences'): |
|
save_preferences() |
|
st.success('Preferences saved successfully!') |
|
|
|
def save_preferences(): |
|
"""Save the preferences sets to a JSON file.""" |
|
with open('preferences_sets.json', 'w') as file: |
|
json.dump(st.session_state['preferences_sets'], file, indent=4) |
|
|
|
if __name__ == "__main__": |
|
app() |
|
|