File size: 1,306 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
import json
import streamlit as st

def app():
    st.header("Identify Your Core Values")

    core_value_questions = [
        "What annoys you or gets under your skin at work?",
        "What brings you joy in your work?",
        "What could you not live without in a workplace or on a work team?",
        "Who do you admire and what do you admire about them?"
    ]


    if 'core_values_responses' not in st.session_state:
        st.session_state['core_values_responses'] = {question: "" for question in core_value_questions}

    def update_response(question):
        new_value = st.session_state[question]
        st.session_state.core_values_responses[question] = new_value


    for question in core_value_questions:
        st.text_input(
            label=question,
            value=st.session_state.core_values_responses[question],
            key=question,
            on_change=update_response,
            args=(question,)
        )

    if st.button('Save Core Values', key='save'):
       save_responses_to_file(st.session_state.core_values_responses)
       st.success('Core Values saved!')

def save_responses_to_file(responses, file_path='core_values_responses.json'):
    with open(file_path, 'w') as file:
        json.dump(responses, file)


if __name__ == "__main__":
    app()