Update my_pages/home.py
Browse files- my_pages/home.py +74 -48
my_pages/home.py
CHANGED
|
@@ -1,63 +1,89 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from streamlit_extras.stylable_container import stylable_container
|
| 3 |
from utils import go_to
|
|
|
|
| 4 |
|
| 5 |
def render():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
st.markdown(
|
| 7 |
"""
|
| 8 |
<style>
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
padding: 0!important;
|
| 13 |
-
margin: 0!important;
|
| 14 |
-
text-decoration: none;
|
| 15 |
-
text-align: justify!important;
|
| 16 |
-
cursor: pointer;
|
| 17 |
-
border: none !important;
|
| 18 |
-
display: inline!important;
|
| 19 |
-
font-size: 50px;
|
| 20 |
font-weight: bold;
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
-
|
|
|
|
| 23 |
text-decoration: underline;
|
| 24 |
-
color: #3366cc !important;
|
| 25 |
-
}
|
| 26 |
-
button[kind="primary"]:focus {
|
| 27 |
-
outline: none !important;
|
| 28 |
-
box-shadow: none !important;
|
| 29 |
-
color: #3366cc !important;
|
| 30 |
-
}
|
| 31 |
-
button[kind="primary"] span {
|
| 32 |
-
font-size: 50px !important;
|
| 33 |
-
font-weight: bold !important;
|
| 34 |
}
|
| 35 |
</style>
|
| 36 |
""",
|
| 37 |
-
unsafe_allow_html=True
|
| 38 |
)
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from utils import go_to
|
| 3 |
+
import streamlit.components.v1 as components
|
| 4 |
|
| 5 |
def render():
|
| 6 |
+
# Initialize session state for clicked page
|
| 7 |
+
if "clicked_page" not in st.session_state:
|
| 8 |
+
st.session_state.clicked_page = None
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# CSS for paragraph styling
|
| 12 |
st.markdown(
|
| 13 |
"""
|
| 14 |
<style>
|
| 15 |
+
.clickable-text {
|
| 16 |
+
text-align: justify;
|
| 17 |
+
font-size: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
font-weight: bold;
|
| 19 |
+
color: green;
|
| 20 |
+
cursor: pointer;
|
| 21 |
+
margin-right: 10px;
|
| 22 |
}
|
| 23 |
+
.clickable-text:hover {
|
| 24 |
+
color: #3366cc;
|
| 25 |
text-decoration: underline;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}
|
| 27 |
</style>
|
| 28 |
""",
|
| 29 |
+
unsafe_allow_html=True
|
| 30 |
)
|
| 31 |
|
| 32 |
+
# Paragraph with clickable spans
|
| 33 |
+
html_code = """
|
| 34 |
+
<p>
|
| 35 |
+
<span class='clickable-text' onclick="window.parent.postMessage({isStreamlitMessage: true, type: 'customEvent', page: 'information_loss'}, '*')">
|
| 36 |
+
Translating real world into concrete data to train AI models leads to inherent loss in information.
|
| 37 |
+
</span>
|
| 38 |
+
<span class='clickable-text' onclick="window.parent.postMessage({isStreamlitMessage: true, type: 'customEvent', page: 'rashomon_effect'}, '*')">
|
| 39 |
+
This loss in information leaves room for multiple interpretations of the data, known as the Rashomon effect.
|
| 40 |
+
This can lead to conflicting predictions across various interpretations for individuals, known as Multiplicity.
|
| 41 |
+
</span>
|
| 42 |
+
<span class='clickable-text' onclick="window.parent.postMessage({isStreamlitMessage: true, type: 'customEvent', page: 'developer_decisions'}, '*')">
|
| 43 |
+
Model developers play an important role steering the model across multiple interpretations, leading to a particular choice.
|
| 44 |
+
</span>
|
| 45 |
+
<span class='clickable-text' onclick="window.parent.postMessage({isStreamlitMessage: true, type: 'customEvent', page: 'ica'}, '*')">
|
| 46 |
+
ICA Framework Sent4.
|
| 47 |
+
</span>
|
| 48 |
+
<span class='clickable-text' onclick="window.parent.postMessage({isStreamlitMessage: true, type: 'customEvent', page: 'multiverse'}, '*')">
|
| 49 |
+
Multiverse Sent5.
|
| 50 |
+
</span>
|
| 51 |
+
</p>
|
| 52 |
+
"""
|
| 53 |
+
|
| 54 |
+
# sentences = [
|
| 55 |
+
# ("Translating real world into concrete data to train AI models leads to inherent loss in information.", "information_loss"),
|
| 56 |
+
# ("This loss in information leaves room for multiple interpretations of the data, known as the Rashomon effect. \
|
| 57 |
+
# This can lead to conflicting predictions across various interpretations for individuals, known as Multiplicity.", "rashomon_effect"),
|
| 58 |
+
# ("Model developers play an important role steering the model across multiple interpretations, leading to a particular choice.", "developer_decisions"),
|
| 59 |
+
# ("ICA Framework.", "ica"),
|
| 60 |
+
# ("Multiverse", "multiverse"),
|
| 61 |
+
# ]
|
| 62 |
+
# color_dict = {"information_loss": "#FF6B6B", "rashomon_effect": "#FFD93D", "developer_decisions": "#6BCB77", "ica": "#FF9F1C", "multiverse": "#9D4EDD"}
|
| 63 |
+
|
| 64 |
+
components.html(html_code, height=100)
|
| 65 |
+
|
| 66 |
+
# Listen for JS messages
|
| 67 |
+
clicked = st.experimental_get_query_params().get("clicked_page", [None])[0]
|
| 68 |
+
if clicked:
|
| 69 |
+
st.session_state.clicked_page = clicked
|
| 70 |
+
|
| 71 |
+
# Trigger navigation
|
| 72 |
+
if st.session_state.clicked_page:
|
| 73 |
+
go_to(st.session_state.clicked_page)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
# button_clicked_dict = {k[1]: False for k in sentences}
|
| 77 |
+
# for text, page in sentences:
|
| 78 |
+
# with stylable_container(
|
| 79 |
+
# page,
|
| 80 |
+
# css_styles=f"""
|
| 81 |
+
# button {{
|
| 82 |
+
# color: {color_dict[page]};
|
| 83 |
+
# }}""",
|
| 84 |
+
# ):
|
| 85 |
+
# button_clicked_dict[page] = st.button(text, type="primary")
|
| 86 |
+
|
| 87 |
+
# for page in button_clicked_dict:
|
| 88 |
+
# if button_clicked_dict[page]:
|
| 89 |
+
# go_to(page)
|