add furniture to empty room and furnish it
To upload files, please first save the app
import streamlit as st
import pandas as pd
st.title("Room Designer")
# Initialize session state for furniture items
if "furniture" not in st.session_state:
st.session_state.furniture = []
# Available furniture options
furniture_options = {
"Bed": {"price": 799.99, "dimensions": "Queen size - 60x80 inches"},
"Sofa": {"price": 699.99, "dimensions": "Three-seater - 84x36 inches"},
"Dining Table": {"price": 399.99, "dimensions": "Rectangle - 72x36 inches"},
"Chair": {"price": 149.99, "dimensions": "Standard - 18x22 inches"},
"Coffee Table": {"price": 199.99, "dimensions": "Rectangle - 48x24 inches"},
"Bookshelf": {"price": 299.99, "dimensions": "5-tier - 36x72 inches"},
"Desk": {"price": 249.99, "dimensions": "Computer desk - 48x24 inches"},
"Dresser": {"price": 449.99, "dimensions": "6-drawer - 60x20 inches"}
}
# Sidebar for adding furniture
with st.sidebar:
st.header("Add Furniture")
furniture_type = st.selectbox("Select Furniture", list(furniture_options.keys()))
quantity = st.number_input("Quantity", min_value=1, max_value=10, value=1)
if st.button("Add to Room"):
new_item = {
"item": furniture_type,
"quantity": quantity,
"price": furniture_options[furniture_type]["price"],
"dimensions": furniture_options[furniture_type]["dimensions"]
}
st.session_state.furniture.append(new_item)
st.success(f"Added {quantity} {furniture_type}(s) to the room!")
# Main content area
st.header("Your Room Design")
if not st.session_state.furniture:
st.info("Your room is empty. Start adding furniture from the sidebar!")
else:
# Display current furniture
furniture_df = pd.DataFrame(st.session_state.furniture)
furniture_df["total_price"] = furniture_df["price"] * furniture_df["quantity"]
st.subheader("Current Furniture")
st.table(furniture_df[["item", "quantity", "dimensions", "price", "total_price"]])
# Calculate and display total cost
total_cost = furniture_df["total_price"].sum()
st.metric("Total Cost", f"${total_cost:,.2f}")
# Option to clear the room
if st.button("Clear Room"):
st.session_state.furniture = []
st.rerun()
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?