Spaces:
Running
Running
import streamlit as st | |
import matplotlib.pyplot as plt | |
# Uygulama başlığı ve stil ayarları | |
st.set_page_config(page_title="Etsy Profit Margin Calculator", layout="wide") | |
# CSS for custom styling | |
st.markdown(""" | |
<style> | |
.card { | |
background-color: #f8f9fa; | |
border-radius: 10px; | |
padding: 20px; | |
margin: 10px 0; | |
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1); | |
} | |
.icon { | |
font-size: 30px; | |
margin-right: 10px; | |
} | |
.calculate-button { | |
background-color: #007bff; | |
color: white; | |
border: none; | |
padding: 10px 20px; | |
border-radius: 5px; | |
font-size: 18px; | |
cursor: pointer; | |
} | |
.header { | |
font-size: 24px; | |
font-weight: bold; | |
} | |
</style> | |
""", unsafe_allow_html=True) | |
# Üst başlık ve açıklama | |
st.markdown("<h2 style='text-align: center;'>Calculate Your Profit Margin on Etsy, Don’t Make A LOSS!</h2>", unsafe_allow_html=True) | |
# Kullanıcı girdi alanları | |
col1, col2, col3 = st.columns(3) | |
with col1: | |
st.markdown("<div class='card'><span class='icon'>💰</span> <span class='header'>Store Currency</span>", unsafe_allow_html=True) | |
currency = st.selectbox("Currency", ["USD", "EUR"]) | |
st.markdown("<div class='card'><span class='icon'>🌍</span> <span class='header'>Store Location</span>", unsafe_allow_html=True) | |
location = st.selectbox("Location", ["US", "EU", "Other"]) | |
with col2: | |
st.markdown("<div class='card'><span class='icon'>💲</span> <span class='header'>Revenue</span>", unsafe_allow_html=True) | |
sale_price = st.number_input("Sale Price ($)", min_value=0.0) | |
shipping_price = st.number_input("Shipping Price ($)", min_value=0.0) | |
gift_wrap = st.number_input("Gift Wrap Price ($)", min_value=0.0) | |
with col3: | |
st.markdown("<div class='card'><span class='icon'>💸</span> <span class='header'>Cost</span>", unsafe_allow_html=True) | |
product_cost = st.number_input("Product Cost ($)", min_value=0.0) | |
labor_cost = st.number_input("Labor Cost ($)", min_value=0.0) | |
packaging_cost = st.number_input("Packaging Cost ($)", min_value=0.0) | |
# Hesaplama | |
if st.button("Hesapla", key="calculate"): | |
total_revenue = sale_price + shipping_price + gift_wrap | |
total_cost = product_cost + labor_cost + packaging_cost | |
profit = total_revenue - total_cost | |
profit_margin = (profit / total_revenue) * 100 if total_revenue > 0 else 0 | |
# Sonuçları göster | |
st.markdown("<div class='card'><span class='icon'>📊</span> <span class='header'>Results</span>", unsafe_allow_html=True) | |
st.write("Total Revenue: $", total_revenue) | |
st.write("Total Cost: $", total_cost) | |
st.write("Profit: $", profit) | |
st.write("Profit Margin: ", f"{profit_margin:.2f}%") | |
# Pasta grafiği | |
labels = ["Cost", "Profit"] | |
sizes = [total_cost, profit] | |
colors = ["#ff9999", "#66b3ff"] | |
fig1, ax1 = plt.subplots() | |
ax1.pie(sizes, labels=labels, colors=colors, autopct='%1.1f%%', startangle=90) | |
ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle. | |
st.pyplot(fig1) | |