ez326 commited on
Commit
e607035
·
verified ·
1 Parent(s): ab57869

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -128,16 +128,24 @@ 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
- # Use two columns: one for the combined title/description, one for the include checkbox.
132
  cols = st.columns([7, 0.5])
133
- # Insert three non-breaking spaces between title and description.
134
- combined = f"<span class='criteria-name'>{crit['name']}</span>&nbsp;&nbsp;&nbsp;<span class='criteria-description'>{crit['description']}</span>"
135
- cols[0].markdown(combined, unsafe_allow_html=True)
136
- include = cols[1].checkbox("", value=True, key=f"include_{group}_{idx}")
137
- # Slider appears immediately below
138
- rating = st.slider("", 1.0, 7.0, 4.0, step=0.1, key=f"slider_{group}_{idx}", disabled=(not include))
 
 
 
 
 
 
 
 
139
  ratings.append(None if not include else rating)
140
 
 
141
  if st.button("Calculate Score"):
142
  result = calculate_score(ratings)
143
  st.markdown(f"<h2 style='text-align:center;'>{result}</h2>", unsafe_allow_html=True)
 
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([7, 0.5])
132
+ combined_col = cols[0]
133
+ checkbox_col = cols[1]
134
+ # Define combined variable with the title and description
135
+ combined = (
136
+ f"<span class='criteria-name'>{crit['name']}</span>"
137
+ f"&nbsp;&nbsp;&nbsp;"
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.1, key=f"slider_{group}_{idx}", disabled=(not include)
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)