Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,43 +19,65 @@ languages = {
|
|
| 19 |
"Chinese": "zh"
|
| 20 |
}
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# Streamlit app configuration
|
| 23 |
st.set_page_config(page_title="International Solar Designer", layout="centered")
|
|
|
|
|
|
|
| 24 |
selected_language = st.sidebar.selectbox("Select Language", options=list(languages.keys()))
|
| 25 |
lang_code = languages[selected_language]
|
| 26 |
|
| 27 |
# App title
|
| 28 |
st.title(translate_text("Solar System Designer", lang_code))
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
# Battery efficiency
|
| 31 |
battery_types = {"Lithium-Ion": 0.95, "Lead-Acid": 0.8}
|
| 32 |
battery_choice = st.selectbox(translate_text("Select Battery Type", lang_code), options=battery_types.keys())
|
| 33 |
battery_efficiency = battery_types[battery_choice]
|
| 34 |
|
| 35 |
-
# Appliance
|
| 36 |
-
|
| 37 |
-
appliances = [
|
| 38 |
-
"LED Bulb", "Fan", "Refrigerator", "Microwave Oven",
|
| 39 |
-
"Water Pump", "Iron", "Inverter AC", "Dishwasher",
|
| 40 |
-
"Geyser", "Heater", "Computer", "Water Dispenser", "Others"
|
| 41 |
-
]
|
| 42 |
-
|
| 43 |
-
selected_appliances = st.multiselect(translate_text("Choose Appliances:", lang_code), options=appliances)
|
| 44 |
-
|
| 45 |
-
# Appliance input
|
| 46 |
-
appliance_data = []
|
| 47 |
-
for appliance in selected_appliances:
|
| 48 |
wattage = st.number_input(
|
| 49 |
-
translate_text(f"{
|
| 50 |
)
|
| 51 |
hours = st.number_input(
|
| 52 |
-
translate_text(f"{
|
| 53 |
)
|
| 54 |
quantity = st.number_input(
|
| 55 |
-
translate_text(f"{
|
| 56 |
)
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
# Calculate recommendations
|
| 61 |
if st.button(translate_text("Calculate Recommendations", lang_code)):
|
|
@@ -111,3 +133,4 @@ if st.button(translate_text("Calculate Recommendations", lang_code)):
|
|
| 111 |
|
| 112 |
|
| 113 |
|
|
|
|
|
|
| 19 |
"Chinese": "zh"
|
| 20 |
}
|
| 21 |
|
| 22 |
+
# Appliance list
|
| 23 |
+
appliance_list = [
|
| 24 |
+
"1. LED Bulb",
|
| 25 |
+
"2. Fan",
|
| 26 |
+
"3. LED TV",
|
| 27 |
+
"4. Computer",
|
| 28 |
+
"5. Refrigerator",
|
| 29 |
+
"6. Washing Machine",
|
| 30 |
+
"7. Water Pump",
|
| 31 |
+
"8. Iron",
|
| 32 |
+
"9. Microwave Oven",
|
| 33 |
+
"10. Water Dispenser",
|
| 34 |
+
"11. Geyser",
|
| 35 |
+
"12. Heater",
|
| 36 |
+
"13. Dishwasher",
|
| 37 |
+
"14. Inverter AC",
|
| 38 |
+
"15. Others",
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
# Streamlit app configuration
|
| 42 |
st.set_page_config(page_title="International Solar Designer", layout="centered")
|
| 43 |
+
|
| 44 |
+
# Sidebar language selection
|
| 45 |
selected_language = st.sidebar.selectbox("Select Language", options=list(languages.keys()))
|
| 46 |
lang_code = languages[selected_language]
|
| 47 |
|
| 48 |
# App title
|
| 49 |
st.title(translate_text("Solar System Designer", lang_code))
|
| 50 |
|
| 51 |
+
# Sidebar appliance selection
|
| 52 |
+
st.sidebar.subheader(translate_text("Select Appliances", lang_code))
|
| 53 |
+
appliance_name = st.sidebar.selectbox("Choose Appliance", appliance_list)
|
| 54 |
+
|
| 55 |
+
if appliance_name == "15. Others":
|
| 56 |
+
appliance_name = st.sidebar.text_input("Enter Appliance Name", "")
|
| 57 |
+
|
| 58 |
# Battery efficiency
|
| 59 |
battery_types = {"Lithium-Ion": 0.95, "Lead-Acid": 0.8}
|
| 60 |
battery_choice = st.selectbox(translate_text("Select Battery Type", lang_code), options=battery_types.keys())
|
| 61 |
battery_efficiency = battery_types[battery_choice]
|
| 62 |
|
| 63 |
+
# Appliance input fields
|
| 64 |
+
if appliance_name != "15. Others":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
wattage = st.number_input(
|
| 66 |
+
translate_text(f"{appliance_name} - Wattage (W):", lang_code), min_value=0, step=1, key=f"{appliance_name}_wattage"
|
| 67 |
)
|
| 68 |
hours = st.number_input(
|
| 69 |
+
translate_text(f"{appliance_name} - Daily Usage (hours):", lang_code), min_value=0, step=1, key=f"{appliance_name}_hours"
|
| 70 |
)
|
| 71 |
quantity = st.number_input(
|
| 72 |
+
translate_text(f"{appliance_name} - Quantity:", lang_code), min_value=0, step=1, key=f"{appliance_name}_quantity"
|
| 73 |
)
|
| 74 |
+
else:
|
| 75 |
+
st.warning(translate_text("Please select an appliance to enter details.", lang_code))
|
| 76 |
+
|
| 77 |
+
# Collecting data if appliance details are provided
|
| 78 |
+
appliance_data = []
|
| 79 |
+
if wattage > 0 and hours > 0 and quantity > 0:
|
| 80 |
+
appliance_data.append({"Appliance": appliance_name, "Wattage": wattage, "Hours": hours, "Quantity": quantity})
|
| 81 |
|
| 82 |
# Calculate recommendations
|
| 83 |
if st.button(translate_text("Calculate Recommendations", lang_code)):
|
|
|
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
+
|