Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Function to convert all units to square meters
|
| 4 |
+
def convert_to_sqm(length, width, unit):
|
| 5 |
+
if unit == "Meters (m)":
|
| 6 |
+
return length * width
|
| 7 |
+
elif unit == "Centimeters (cm)":
|
| 8 |
+
return (length / 100) * (width / 100)
|
| 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 |
+
# Input for main 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")
|
| 23 |
+
width = st.number_input("Enter Width:", min_value=0.0, format="%.2f")
|
| 24 |
+
|
| 25 |
+
# Calculate area
|
| 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 |
+
|
| 33 |
+
excluded_area = convert_to_sqm(exclude_length, exclude_width, unit)
|
| 34 |
+
final_area = total_area - excluded_area
|
| 35 |
+
|
| 36 |
+
st.markdown(f"### ✅ Total Area: `{final_area:.2f} m²`")
|
| 37 |
+
|
| 38 |
+
# Gypsum board calculation
|
| 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 |
+
|