careerv3 / preference.py
ombhojane's picture
Upload 88 files
8d404bc verified
raw
history blame contribute delete
No virus
1.7 kB
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"]
# Initialize preferences sets in session state if it doesn't exist
if 'preferences_sets' not in st.session_state:
st.session_state.preferences_sets = [{}]
# Function to add another set of preferences
def add_another_set():
st.session_state.preferences_sets.append({})
# Display current sets of preferences
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()