Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
import streamlit as st
|
| 3 |
+
|
| 4 |
+
def calculate_tiles(area_length, area_width, area_height, tile_length, tile_width, door_area=0, exhaust_area=0):
|
| 5 |
+
# Calculate the area of the floor
|
| 6 |
+
floor_area = area_length * area_width
|
| 7 |
+
|
| 8 |
+
# Calculate the area of the walls
|
| 9 |
+
wall_area = 2 * (area_length * area_height) + 2 * (area_width * area_height) - (door_area + exhaust_area)
|
| 10 |
+
|
| 11 |
+
# Calculate the total area to be tiled
|
| 12 |
+
total_area = floor_area + wall_area
|
| 13 |
+
|
| 14 |
+
# Calculate the area of one tile
|
| 15 |
+
tile_area = tile_length * tile_width
|
| 16 |
+
|
| 17 |
+
# Calculate the number of tiles required
|
| 18 |
+
num_tiles = total_area / tile_area
|
| 19 |
+
|
| 20 |
+
return floor_area, wall_area, total_area, num_tiles
|
| 21 |
+
|
| 22 |
+
def calculate_bond_bags(num_tiles, bag_weight):
|
| 23 |
+
# Estimate number of bond bags required
|
| 24 |
+
# Assuming 1 bag covers 10 tiles as an average consumption
|
| 25 |
+
tiles_per_bag = 10 # Adjust this based on practical considerations
|
| 26 |
+
num_bags = num_tiles / tiles_per_bag
|
| 27 |
+
|
| 28 |
+
return num_bags
|
| 29 |
+
|
| 30 |
+
def main():
|
| 31 |
+
st.set_page_config(page_title="Tile Calculator", page_icon="π", layout="centered")
|
| 32 |
+
|
| 33 |
+
# Title and description
|
| 34 |
+
st.title("π Tile Calculator App")
|
| 35 |
+
st.markdown(
|
| 36 |
+
"""
|
| 37 |
+
Welcome to the Tile Calculator! π¨ Use this app to calculate the number of tiles required for walls and floors, adjust for doors and exhaust spaces, and estimate the bond bags required.
|
| 38 |
+
"""
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
# Input fields for room dimensions
|
| 42 |
+
st.header("Room Dimensions")
|
| 43 |
+
area_length = st.number_input("Room Length (in feet):", min_value=0.0, step=0.1, format="%.2f")
|
| 44 |
+
area_width = st.number_input("Room Width (in feet):", min_value=0.0, step=0.1, format="%.2f")
|
| 45 |
+
area_height = st.number_input("Room Height (in feet):", min_value=0.0, step=0.1, format="%.2f")
|
| 46 |
+
|
| 47 |
+
# Input fields for tile dimensions
|
| 48 |
+
st.header("Tile Dimensions")
|
| 49 |
+
tile_length = st.number_input("Tile Length (in feet):", min_value=0.0, step=0.1, format="%.2f")
|
| 50 |
+
tile_width = st.number_input("Tile Width (in feet):", min_value=0.0, step=0.1, format="%.2f")
|
| 51 |
+
|
| 52 |
+
# Input fields for door and exhaust areas
|
| 53 |
+
st.header("Adjustments for Doors and Exhaust")
|
| 54 |
+
door_area = st.number_input("Total Door Area (in square feet):", min_value=0.0, step=0.1, format="%.2f")
|
| 55 |
+
exhaust_area = st.number_input("Total Exhaust Area (in square feet):", min_value=0.0, step=0.1, format="%.2f")
|
| 56 |
+
|
| 57 |
+
# Button to calculate tiles
|
| 58 |
+
if st.button("Calculate Tiles"):
|
| 59 |
+
if area_length > 0 and area_width > 0 and area_height > 0 and tile_length > 0 and tile_width > 0:
|
| 60 |
+
floor_area, wall_area, total_area, num_tiles = calculate_tiles(
|
| 61 |
+
area_length, area_width, area_height, tile_length, tile_width, door_area, exhaust_area
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
st.success("Calculation Complete!")
|
| 65 |
+
st.subheader("Results")
|
| 66 |
+
st.write(f"**Floor Area:** {floor_area:.2f} sq. feet")
|
| 67 |
+
st.write(f"**Wall Area (adjusted for doors and exhaust):** {wall_area:.2f} sq. feet")
|
| 68 |
+
st.write(f"**Total Area to be Tiled:** {total_area:.2f} sq. feet")
|
| 69 |
+
st.write(f"**Number of Tiles Required:** {num_tiles:.0f}")
|
| 70 |
+
|
| 71 |
+
# Input field for bond bag weight and calculation
|
| 72 |
+
st.header("Bond Bag Estimation")
|
| 73 |
+
bag_weight = st.number_input("Weight of one bond bag (in kg):", min_value=0.0, step=0.1, format="%.2f")
|
| 74 |
+
if bag_weight > 0:
|
| 75 |
+
num_bags = calculate_bond_bags(num_tiles, bag_weight)
|
| 76 |
+
st.write(f"**Estimated Number of Bond Bags Required:** {num_bags:.0f}")
|
| 77 |
+
else:
|
| 78 |
+
st.warning("Please enter a valid weight for the bond bag.")
|
| 79 |
+
else:
|
| 80 |
+
st.error("Please enter all dimensions greater than zero.")
|
| 81 |
+
|
| 82 |
+
# Footer
|
| 83 |
+
st.markdown(
|
| 84 |
+
"""
|
| 85 |
+
---
|
| 86 |
+
Created with π by [Your Name](https://huggingface.co/).
|
| 87 |
+
"""
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
if __name__ == "__main__":
|
| 91 |
+
main()
|