engrmuhammadrizwan01's picture
Update app.py
77cab99 verified
# app.py
import streamlit as st
def calculate_tiles(area_length, area_width, area_height, tile_length, tile_width, door_area=0, exhaust_area=0):
# Calculate the area of the floor
floor_area = area_length * area_width
# Calculate the area of the walls
wall_area = 2 * (area_length * area_height) + 2 * (area_width * area_height) - (door_area + exhaust_area)
# Calculate the total area to be tiled
total_area = floor_area + wall_area
# Calculate the area of one tile
tile_area = tile_length * tile_width
# Calculate the number of tiles required
num_tiles = total_area / tile_area
return floor_area, wall_area, total_area, num_tiles
def calculate_bond_bags(num_tiles, tiles_per_bag):
# Calculate the number of bond bags required
num_bags = num_tiles / tiles_per_bag
return num_bags
def main():
st.set_page_config(page_title="Tile Calculator", page_icon="🌐", layout="centered")
# Title and description
st.title("🌐 Tile Calculator App")
st.markdown(
"""
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.
"""
)
# Input fields for room dimensions
st.header("Room Dimensions")
area_length = st.number_input("Room Length (in feet):", min_value=0.0, step=0.1, format="%.2f")
area_width = st.number_input("Room Width (in feet):", min_value=0.0, step=0.1, format="%.2f")
area_height = st.number_input("Room Height (in feet):", min_value=0.0, step=0.1, format="%.2f")
# Input fields for tile dimensions
st.header("Tile Dimensions")
tile_length = st.number_input("Tile Length (in feet):", min_value=0.0, step=0.1, format="%.2f")
tile_width = st.number_input("Tile Width (in feet):", min_value=0.0, step=0.1, format="%.2f")
# Input fields for door and exhaust areas
st.header("Adjustments for Doors and Exhaust")
door_area = st.number_input("Total Door Area (in square feet):", min_value=0.0, step=0.1, format="%.2f")
exhaust_area = st.number_input("Total Exhaust Area (in square feet):", min_value=0.0, step=0.1, format="%.2f")
# Button to calculate tiles
if st.button("Calculate Tiles"):
if area_length > 0 and area_width > 0 and area_height > 0 and tile_length > 0 and tile_width > 0:
floor_area, wall_area, total_area, num_tiles = calculate_tiles(
area_length, area_width, area_height, tile_length, tile_width, door_area, exhaust_area
)
st.success("Calculation Complete!")
st.subheader("Results")
st.write(f"**Floor Area:** {floor_area:.2f} sq. feet")
st.write(f"**Wall Area (adjusted for doors and exhaust):** {wall_area:.2f} sq. feet")
st.write(f"**Total Area to be Tiled:** {total_area:.2f} sq. feet")
st.write(f"**Number of Tiles Required:** {num_tiles:.0f}")
# Input field for bond bag weight and calculation
st.header("Bond Bag Estimation")
tiles_per_bag = st.number_input("Number of tiles covered per bond bag:", min_value=0.0, step=0.1, format="%.2f")
if tiles_per_bag > 0:
num_bags = calculate_bond_bags(num_tiles, tiles_per_bag)
st.write(f"**Estimated Number of Bond Bags Required:** {num_bags:.0f}")
else:
st.warning("Please enter a valid number of tiles covered per bond bag.")
else:
st.error("Please enter all dimensions greater than zero.")
# Footer
st.markdown(
"""
---
Created with πŸš€ by [Your Name](https://huggingface.co/).
"""
)
if __name__ == "__main__":
main()