Becer commited on
Commit
3db00a9
·
1 Parent(s): e732519

Fixed value calculation: corrected user input handling

Browse files
Files changed (1) hide show
  1. app.py +20 -18
app.py CHANGED
@@ -103,31 +103,32 @@ if uploaded_file:
103
  user_inputs = {}
104
 
105
  # 🎛️ Left Column - Grouped Items
 
 
106
  with col1:
107
  st.subheader("🛍️ Select item quantities:")
108
  for category, items in categories.items():
109
  with st.expander(category, expanded=True):
110
  for _, row in df[df["Name"].isin(items)].iterrows():
111
- with st.container():
112
- # Wyświetlanie produktu z pogrubioną nazwą i kursywą cen
 
 
113
  st.markdown(f"""
114
- <div class='item-container'>
115
- <div style="display: flex; justify-content: space-between; align-items: center;">
116
- <div>
117
- <p class='item-name' style="font-size: 18px; font-weight: bold;">{row['Name']}</p>
118
- <p class='item-price' style="font-size: 14px; font-style: italic; color: gray;">
119
- HR: {row['HR Min']:.2f}-{row['HR Max']:.2f},
120
- Gul: {row['GUL Min']:.2f}-{row['GUL Max']:.2f},
121
- WSS: {row['WSS Min']:.2f}-{row['WSS Max']:.2f}
122
- </p>
123
- </div>
124
- <div>
125
- {st.number_input("", min_value=0, step=1, key=row['Name'])}
126
- </div>
127
- </div>
128
- </div>
129
  """, unsafe_allow_html=True)
130
 
 
 
 
 
 
 
131
  # 📊 Right Column - Summary
132
  with col2:
133
  st.subheader("📊 Summary")
@@ -150,6 +151,7 @@ if uploaded_file:
150
  total_wss_min += quantity * row['WSS Min']
151
  total_wss_max += quantity * row['WSS Max']
152
 
 
153
  st.markdown(f"""
154
  <div class='summary-box'>
155
  <p class='summary-title'>🧾 Total Value</p>
@@ -157,4 +159,4 @@ if uploaded_file:
157
  <p class='summary-value'><strong>Gul:</strong> {total_gul_min:.2f} - {total_gul_max:.2f}</p>
158
  <p class='summary-value'><strong>WSS:</strong> {total_wss_min:.2f} - {total_wss_max:.2f}</p>
159
  </div>
160
- """, unsafe_allow_html=True)
 
103
  user_inputs = {}
104
 
105
  # 🎛️ Left Column - Grouped Items
106
+ user_inputs = {} # Przechowywanie wartości wpisanych przez użytkownika
107
+
108
  with col1:
109
  st.subheader("🛍️ Select item quantities:")
110
  for category, items in categories.items():
111
  with st.expander(category, expanded=True):
112
  for _, row in df[df["Name"].isin(items)].iterrows():
113
+ col_left, col_right = st.columns([3, 1]) # Podział na kolumny dla lepszego wyglądu
114
+
115
+ # 🏷️ Wyświetlanie nazwy przedmiotu i ceny (kursywa)
116
+ with col_left:
117
  st.markdown(f"""
118
+ <p style="font-size: 18px; font-weight: bold;">{row['Name']}</p>
119
+ <p style="font-size: 14px; font-style: italic; color: gray;">
120
+ HR: {row['HR Min']:.2f}-{row['HR Max']:.2f},
121
+ Gul: {row['GUL Min']:.2f}-{row['GUL Max']:.2f},
122
+ WSS: {row['WSS Min']:.2f}-{row['WSS Max']:.2f}
123
+ </p>
 
 
 
 
 
 
 
 
 
124
  """, unsafe_allow_html=True)
125
 
126
+ # 🔢 Pole do wpisania ilości (przypisane do `user_inputs`)
127
+ with col_right:
128
+ user_inputs[row['Name']] = st.number_input(
129
+ "", min_value=0, step=1, key=row['Name']
130
+ )
131
+
132
  # 📊 Right Column - Summary
133
  with col2:
134
  st.subheader("📊 Summary")
 
151
  total_wss_min += quantity * row['WSS Min']
152
  total_wss_max += quantity * row['WSS Max']
153
 
154
+ # 🔥 Wyświetlenie poprawnej sumy wartości
155
  st.markdown(f"""
156
  <div class='summary-box'>
157
  <p class='summary-title'>🧾 Total Value</p>
 
159
  <p class='summary-value'><strong>Gul:</strong> {total_gul_min:.2f} - {total_gul_max:.2f}</p>
160
  <p class='summary-value'><strong>WSS:</strong> {total_wss_min:.2f} - {total_wss_max:.2f}</p>
161
  </div>
162
+ """, unsafe_allow_html=True)