Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -4,32 +4,40 @@ st.set_page_config(layout="wide")
|
|
| 4 |
|
| 5 |
css = """
|
| 6 |
<style>
|
| 7 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
.stMarkdown p {
|
| 9 |
margin: 0 !important;
|
| 10 |
padding: 0 !important;
|
|
|
|
| 11 |
}
|
| 12 |
/* Compact styling for criterion name and description */
|
| 13 |
.criteria-name {
|
| 14 |
font-size: 12px;
|
| 15 |
font-weight: bold;
|
|
|
|
| 16 |
}
|
| 17 |
.criteria-description {
|
| 18 |
font-size: 10px;
|
| 19 |
-
color: #
|
| 20 |
}
|
| 21 |
.category-header {
|
| 22 |
margin-top: 6px;
|
| 23 |
margin-bottom: 3px;
|
| 24 |
font-size: 14px;
|
| 25 |
font-weight: bold;
|
| 26 |
-
border-bottom: 1px solid #
|
| 27 |
padding-bottom: 2px;
|
|
|
|
| 28 |
}
|
| 29 |
.app-header {
|
| 30 |
text-align: center;
|
| 31 |
margin-bottom: 6px;
|
| 32 |
font-size: 20px;
|
|
|
|
| 33 |
}
|
| 34 |
/* Enlarge slider thumb for easier touch */
|
| 35 |
div[data-baseweb="slider"] .Thumb {
|
|
@@ -123,29 +131,26 @@ def calculate_score(ratings):
|
|
| 123 |
st.markdown("<h1 class='app-header'>Movie Rating System</h1>", unsafe_allow_html=True)
|
| 124 |
ratings = []
|
| 125 |
|
| 126 |
-
# For each criterion, display a
|
| 127 |
for group, subcriteria in criteria.items():
|
| 128 |
st.markdown(f"<div class='category-header'>{group}</div>", unsafe_allow_html=True)
|
| 129 |
for idx, crit in enumerate(subcriteria):
|
| 130 |
with st.container():
|
| 131 |
-
cols = st.columns([
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
combined = (
|
| 136 |
f"<span class='criteria-name'>{crit['name']}</span>"
|
| 137 |
f" "
|
| 138 |
f"<span class='criteria-description'>{crit['description']}</span>"
|
| 139 |
)
|
| 140 |
combined_col.markdown(combined, unsafe_allow_html=True)
|
| 141 |
-
include = checkbox_col.checkbox("", value=True, key=f"include_{group}_{idx}")
|
| 142 |
-
# Place slider directly under the text in the same column
|
| 143 |
rating = combined_col.slider(
|
| 144 |
-
"", 1.0, 7.0, 4.0, step=0.
|
| 145 |
)
|
| 146 |
ratings.append(None if not include else rating)
|
| 147 |
|
| 148 |
-
|
| 149 |
if st.button("Calculate Score"):
|
| 150 |
result = calculate_score(ratings)
|
| 151 |
st.markdown(f"<h2 style='text-align:center;'>{result}</h2>", unsafe_allow_html=True)
|
|
|
|
| 4 |
|
| 5 |
css = """
|
| 6 |
<style>
|
| 7 |
+
/* Dark mode and movie theater safe theme */
|
| 8 |
+
body {
|
| 9 |
+
background-color: #121212 !important;
|
| 10 |
+
color: #e0e0e0 !important;
|
| 11 |
+
}
|
| 12 |
.stMarkdown p {
|
| 13 |
margin: 0 !important;
|
| 14 |
padding: 0 !important;
|
| 15 |
+
color: #e0e0e0;
|
| 16 |
}
|
| 17 |
/* Compact styling for criterion name and description */
|
| 18 |
.criteria-name {
|
| 19 |
font-size: 12px;
|
| 20 |
font-weight: bold;
|
| 21 |
+
color: #ffffff;
|
| 22 |
}
|
| 23 |
.criteria-description {
|
| 24 |
font-size: 10px;
|
| 25 |
+
color: #cccccc;
|
| 26 |
}
|
| 27 |
.category-header {
|
| 28 |
margin-top: 6px;
|
| 29 |
margin-bottom: 3px;
|
| 30 |
font-size: 14px;
|
| 31 |
font-weight: bold;
|
| 32 |
+
border-bottom: 1px solid #444;
|
| 33 |
padding-bottom: 2px;
|
| 34 |
+
color: #ffffff;
|
| 35 |
}
|
| 36 |
.app-header {
|
| 37 |
text-align: center;
|
| 38 |
margin-bottom: 6px;
|
| 39 |
font-size: 20px;
|
| 40 |
+
color: #ffffff;
|
| 41 |
}
|
| 42 |
/* Enlarge slider thumb for easier touch */
|
| 43 |
div[data-baseweb="slider"] .Thumb {
|
|
|
|
| 131 |
st.markdown("<h1 class='app-header'>Movie Rating System</h1>", unsafe_allow_html=True)
|
| 132 |
ratings = []
|
| 133 |
|
| 134 |
+
# For each criterion, display a row with the checkbox on the left, then title/description and slider
|
| 135 |
for group, subcriteria in criteria.items():
|
| 136 |
st.markdown(f"<div class='category-header'>{group}</div>", unsafe_allow_html=True)
|
| 137 |
for idx, crit in enumerate(subcriteria):
|
| 138 |
with st.container():
|
| 139 |
+
cols = st.columns([0.5, 7])
|
| 140 |
+
checkbox_col = cols[0]
|
| 141 |
+
combined_col = cols[1]
|
| 142 |
+
include = checkbox_col.checkbox("", value=True, key=f"include_{group}_{idx}")
|
| 143 |
combined = (
|
| 144 |
f"<span class='criteria-name'>{crit['name']}</span>"
|
| 145 |
f" "
|
| 146 |
f"<span class='criteria-description'>{crit['description']}</span>"
|
| 147 |
)
|
| 148 |
combined_col.markdown(combined, unsafe_allow_html=True)
|
|
|
|
|
|
|
| 149 |
rating = combined_col.slider(
|
| 150 |
+
"", 1.0, 7.0, 4.0, step=0.01, key=f"slider_{group}_{idx}", disabled=(not include)
|
| 151 |
)
|
| 152 |
ratings.append(None if not include else rating)
|
| 153 |
|
|
|
|
| 154 |
if st.button("Calculate Score"):
|
| 155 |
result = calculate_score(ratings)
|
| 156 |
st.markdown(f"<h2 style='text-align:center;'>{result}</h2>", unsafe_allow_html=True)
|