Update my_pages/information_loss.py
Browse files- my_pages/information_loss.py +29 -33
my_pages/information_loss.py
CHANGED
|
@@ -3,10 +3,10 @@ import streamlit as st
|
|
| 3 |
from utils import add_navigation, add_instruction_text
|
| 4 |
|
| 5 |
ALL_FEATURES = [
|
| 6 |
-
("Liquid Assets", "Liquid Assets",
|
| 7 |
("Illiquid Assets", "Property appraisals, Insurance valuations, etc.",
|
| 8 |
"Sorry, it is not possible to get the precise value of illiquid assets. We will use some approximate alternatives instead."),
|
| 9 |
-
("Current Debts", "Current Debts",
|
| 10 |
("Income Stability", "Past Income Stability",
|
| 11 |
"Sorry, it is not possible to know precisely how stable someone's income will be in future. Until someone invents a time machine (we're hopeful!), we will instead use past income stability."),
|
| 12 |
("Health Trajectory", "Current Health Indicators",
|
|
@@ -26,54 +26,50 @@ def render():
|
|
| 26 |
"""
|
| 27 |
)
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
| 43 |
|
|
|
|
|
|
|
| 44 |
if "selected_features" not in st.session_state:
|
| 45 |
st.session_state.selected_features = []
|
| 46 |
|
| 47 |
-
|
| 48 |
-
top_left, top_right = st.columns([1, 1])
|
| 49 |
|
| 50 |
-
with
|
| 51 |
st.image(
|
| 52 |
"loan.png",
|
| 53 |
width=100,
|
| 54 |
)
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
st.markdown("**All Features**")
|
| 59 |
-
for feature in ALL_FEATURES.copy():
|
| 60 |
if feature in st.session_state.selected_features:
|
| 61 |
-
|
| 62 |
-
if feature[2] is None:
|
| 63 |
-
_ = st.button(feature_name, type="primary")
|
| 64 |
-
else:
|
| 65 |
-
_ = st.button(feature_name, type="tertiary")
|
| 66 |
else:
|
| 67 |
-
|
| 68 |
-
if st.button(feature_name):
|
| 69 |
st.session_state.selected_features.append(feature)
|
| 70 |
-
|
| 71 |
-
st.session_state.show_message = (feature[2])
|
| 72 |
st.rerun()
|
| 73 |
|
| 74 |
if "show_message" in st.session_state:
|
| 75 |
st.markdown(
|
| 76 |
-
f"<div style='text-align:center; color:#c0392b; font-size:20px;
|
| 77 |
unsafe_allow_html=True,
|
| 78 |
)
|
| 79 |
del st.session_state.show_message
|
|
|
|
| 3 |
from utils import add_navigation, add_instruction_text
|
| 4 |
|
| 5 |
ALL_FEATURES = [
|
| 6 |
+
("Liquid Assets", "Liquid Assets", "Added"),
|
| 7 |
("Illiquid Assets", "Property appraisals, Insurance valuations, etc.",
|
| 8 |
"Sorry, it is not possible to get the precise value of illiquid assets. We will use some approximate alternatives instead."),
|
| 9 |
+
("Current Debts", "Current Debts", "Added"),
|
| 10 |
("Income Stability", "Past Income Stability",
|
| 11 |
"Sorry, it is not possible to know precisely how stable someone's income will be in future. Until someone invents a time machine (we're hopeful!), we will instead use past income stability."),
|
| 12 |
("Health Trajectory", "Current Health Indicators",
|
|
|
|
| 26 |
"""
|
| 27 |
)
|
| 28 |
|
| 29 |
+
#### Setup Button Colors and Theme
|
| 30 |
+
sec_bg = st.get_option("theme.secondaryBackgroundColor")
|
| 31 |
+
text = st.get_option("theme.textColor")
|
| 32 |
+
|
| 33 |
+
css = f"""
|
| 34 |
+
<style>
|
| 35 |
+
button[kind="tertiary"] {{
|
| 36 |
+
background-color: {sec_bg} !important;
|
| 37 |
+
color: {text} !important;
|
| 38 |
+
border: 1px solid {sec_bg} !important;
|
| 39 |
+
opacity: 0.2 !important; /* faded look */
|
| 40 |
+
cursor: not-allowed !important; /* shows it's inactive */
|
| 41 |
+
pointer-events: none !important; /* disable clicking */
|
| 42 |
+
}}
|
| 43 |
+
</style>
|
| 44 |
+
"""
|
| 45 |
+
st.markdown(css, unsafe_allow_html=True)
|
| 46 |
|
| 47 |
+
|
| 48 |
+
#### Add the icon and buttons at the top
|
| 49 |
if "selected_features" not in st.session_state:
|
| 50 |
st.session_state.selected_features = []
|
| 51 |
|
| 52 |
+
cols_list = st.columns([1, 1, 1, 1])
|
|
|
|
| 53 |
|
| 54 |
+
with cols_list[0]:
|
| 55 |
st.image(
|
| 56 |
"loan.png",
|
| 57 |
width=100,
|
| 58 |
)
|
| 59 |
|
| 60 |
+
for ite, feature in enumerate(ALL_FEATURES.copy()):
|
| 61 |
+
with cols_list[ite%3 + 1]:
|
|
|
|
|
|
|
| 62 |
if feature in st.session_state.selected_features:
|
| 63 |
+
_ = st.button(feature[0], type="tertiary")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
else:
|
| 65 |
+
if st.button(feature[0]):
|
|
|
|
| 66 |
st.session_state.selected_features.append(feature)
|
| 67 |
+
st.session_state.show_message = feature[2]
|
|
|
|
| 68 |
st.rerun()
|
| 69 |
|
| 70 |
if "show_message" in st.session_state:
|
| 71 |
st.markdown(
|
| 72 |
+
f"<div style='text-align:center; color:#c0392b; font-size:20px; margin:14px 0;'>{st.session_state.show_message}</div>",
|
| 73 |
unsafe_allow_html=True,
|
| 74 |
)
|
| 75 |
del st.session_state.show_message
|