Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,14 @@ def convert_to_sqm(length, width, unit):
|
|
| 9 |
elif unit == "Millimeters (mm)":
|
| 10 |
return (length / 1000) * (width / 1000)
|
| 11 |
|
| 12 |
-
# Streamlit UI
|
| 13 |
st.set_page_config(page_title="Area & Gypsum Board Calculator", layout="wide")
|
| 14 |
|
| 15 |
st.title("📐 Area & Gypsum Board Calculator")
|
| 16 |
st.markdown("Calculate the total area with unit conversion and estimate gypsum board requirements.")
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
st.subheader("Main Area Input")
|
| 20 |
unit = st.selectbox("Select the unit of measurement:", ["Meters (m)", "Centimeters (cm)", "Millimeters (mm)"])
|
| 21 |
|
| 22 |
length = st.number_input("Enter Length:", min_value=0.0, format="%.2f")
|
|
@@ -26,7 +26,7 @@ width = st.number_input("Enter Width:", min_value=0.0, format="%.2f")
|
|
| 26 |
total_area = convert_to_sqm(length, width, unit)
|
| 27 |
|
| 28 |
# Option to subtract an excluded area
|
| 29 |
-
st.subheader("Excluded Area (Optional)")
|
| 30 |
exclude_length = st.number_input("Enter Length of Excluded Area:", min_value=0.0, format="%.2f", key="ex_len")
|
| 31 |
exclude_width = st.number_input("Enter Width of Excluded Area:", min_value=0.0, format="%.2f", key="ex_wid")
|
| 32 |
|
|
@@ -35,18 +35,28 @@ final_area = total_area - excluded_area
|
|
| 35 |
|
| 36 |
st.markdown(f"### ✅ Total Area: `{final_area:.2f} m²`")
|
| 37 |
|
| 38 |
-
# Gypsum
|
| 39 |
-
st.subheader("Gypsum Board Calculation")
|
| 40 |
gypsum_board_area = st.number_input("Enter Area of a Single Gypsum Board (m²):", min_value=0.1, format="%.2f")
|
| 41 |
|
| 42 |
-
if st.button("Calculate Required Gypsum Boards"):
|
| 43 |
if gypsum_board_area > 0:
|
| 44 |
num_boards = final_area / gypsum_board_area
|
| 45 |
st.success(f"📌 You will need approximately `{num_boards:.2f}` gypsum boards.")
|
| 46 |
else:
|
| 47 |
st.error("Please enter a valid gypsum board area.")
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
# Footer
|
| 50 |
st.markdown("---")
|
| 51 |
st.markdown("Developed with ❤️ using Streamlit.")
|
| 52 |
-
|
|
|
|
| 9 |
elif unit == "Millimeters (mm)":
|
| 10 |
return (length / 1000) * (width / 1000)
|
| 11 |
|
| 12 |
+
# Streamlit UI Configuration
|
| 13 |
st.set_page_config(page_title="Area & Gypsum Board Calculator", layout="wide")
|
| 14 |
|
| 15 |
st.title("📐 Area & Gypsum Board Calculator")
|
| 16 |
st.markdown("Calculate the total area with unit conversion and estimate gypsum board requirements.")
|
| 17 |
|
| 18 |
+
# Section 1: Area Calculation
|
| 19 |
+
st.subheader("🔹 Main Area Input")
|
| 20 |
unit = st.selectbox("Select the unit of measurement:", ["Meters (m)", "Centimeters (cm)", "Millimeters (mm)"])
|
| 21 |
|
| 22 |
length = st.number_input("Enter Length:", min_value=0.0, format="%.2f")
|
|
|
|
| 26 |
total_area = convert_to_sqm(length, width, unit)
|
| 27 |
|
| 28 |
# Option to subtract an excluded area
|
| 29 |
+
st.subheader("🔹 Excluded Area (Optional)")
|
| 30 |
exclude_length = st.number_input("Enter Length of Excluded Area:", min_value=0.0, format="%.2f", key="ex_len")
|
| 31 |
exclude_width = st.number_input("Enter Width of Excluded Area:", min_value=0.0, format="%.2f", key="ex_wid")
|
| 32 |
|
|
|
|
| 35 |
|
| 36 |
st.markdown(f"### ✅ Total Area: `{final_area:.2f} m²`")
|
| 37 |
|
| 38 |
+
# Section 2: Gypsum Board Calculation (Based on Calculated Area)
|
| 39 |
+
st.subheader("🛠 Gypsum Board Calculation")
|
| 40 |
gypsum_board_area = st.number_input("Enter Area of a Single Gypsum Board (m²):", min_value=0.1, format="%.2f")
|
| 41 |
|
| 42 |
+
if st.button("Calculate Required Gypsum Boards (Based on Calculated Area)"):
|
| 43 |
if gypsum_board_area > 0:
|
| 44 |
num_boards = final_area / gypsum_board_area
|
| 45 |
st.success(f"📌 You will need approximately `{num_boards:.2f}` gypsum boards.")
|
| 46 |
else:
|
| 47 |
st.error("Please enter a valid gypsum board area.")
|
| 48 |
|
| 49 |
+
# Section 3: Direct Area Input for Gypsum Board Calculation
|
| 50 |
+
st.subheader("📏 Enter a Custom Area for Gypsum Board Calculation")
|
| 51 |
+
custom_area = st.number_input("Enter Total Area in m²:", min_value=0.0, format="%.2f", key="custom_area")
|
| 52 |
+
|
| 53 |
+
if st.button("Calculate Required Gypsum Boards (Based on Custom Area)"):
|
| 54 |
+
if gypsum_board_area > 0:
|
| 55 |
+
num_boards_custom = custom_area / gypsum_board_area
|
| 56 |
+
st.success(f"📌 You will need approximately `{num_boards_custom:.2f}` gypsum boards.")
|
| 57 |
+
else:
|
| 58 |
+
st.error("Please enter a valid gypsum board area.")
|
| 59 |
+
|
| 60 |
# Footer
|
| 61 |
st.markdown("---")
|
| 62 |
st.markdown("Developed with ❤️ using Streamlit.")
|
|
|