File size: 1,686 Bytes
8d404bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import streamlit as st
import json
def app():
st.header("Career Priorities")
st.write("Rate the following aspects of your career according to your priority, and provide reasons for your choices.")
career_priorities = [
"Money",
"Benefits",
"Creative control",
"Flexible work options",
"Proximity to home/school/daycare",
"Challenge",
"Social connections and camaraderie",
"Measurable success",
]
if 'priorities_data' not in st.session_state:
st.session_state.priorities_data = {aspect: {"rating": None, "reason": ""} for aspect in career_priorities}
for aspect in career_priorities:
with st.expander(f"Rate and Explain: {aspect}"):
current_rating = st.session_state.priorities_data[aspect]["rating"]
current_reason = st.session_state.priorities_data[aspect]["reason"]
st.session_state.priorities_data[aspect]["rating"] = st.slider(
"Priority Rating", min_value=1, max_value=8, value=current_rating if current_rating else 1, key=f"slider_{aspect}"
)
st.session_state.priorities_data[aspect]["reason"] = st.text_area(
"Why is this important to you?", value=current_reason, key=f"text_{aspect}"
)
if st.button('Save Answers'):
save_priorities_data(st.session_state.priorities_data)
st.success('Career Priorities saved successfully!')
def save_priorities_data(data):
"""Save the priorities data to a JSON file."""
with open('career_priorities_data.json', 'w') as file:
json.dump(data, file, indent=4)
if __name__ == "__main__":
app()
|