import tkinter as tk from tkinter import ttk, messagebox
products = { 1: {"name": "Cloth Support", "min": 30, "max": 38}, 2: {"name": "Telescope Shaft", "min": 75, "max": 85} }
def calculate(): try:
selected = product_var.get() prod_id = int(selected.split(" - ")[0])
length = float(length_entry.get())
rate = float(rate_entry.get())
# Product details
product = products[prod_id]
name = product["name"]
min_rate, max_rate = product["min"], product["max"]
# Check agar rate sahi range mein hai
if rate < min_rate or rate > max_rate:
messagebox.showerror("⚠️ Galat Rate",
f"{name} ki rate ₹{min_rate} se ₹{max_rate} ke darmiyan honi chahiye")
return
# Total calculate karo
total = length * rate
result_label.config(text=f"✅ Kull Rasil: ₹{total:,.2f}")
# Bill text
bill_text.set(f"""
🧾 BILL PREVIEW ────────────────────── Product : {name} Length : {length} inch Rate : ₹{rate}/inch ────────────────────── Total : ₹{total:,.2f} ────────────────────── """)
except:
messagebox.showerror("❌ Input Me Ghalti", "Sahi number daalein (length aur rate)")
root = tk.Tk() root.title("🛠️ Utility Store - Billing Software") root.geometry("450x500") root.configure(bg="#f0f0f0")
tk.Label(root, text="🔧 Utility Store Billing", font=("Arial", 16, "bold"), bg="#f0f0f0", fg="#003366").pack(pady=10)
tk.Label(root, text="🔧 Product Chunein:", font=("Arial", 12), bg="#f0f0f0").pack(pady=5) product_var = tk.StringVar() product_combo = ttk.Combobox(root, textvariable=product_var, width=30, state="readonly", font=("Arial", 11)) product_combo['values'] = [f"{k} - {v['name']}" for k, v in products.items()] product_combo.pack(pady=5)
tk.Label(root, text="📏 Length (Inches) mein:", font=("Arial", 12), bg="#f0f0f0").pack(pady=5) length_entry = tk.Entry(root, width=30, font=("Arial", 11), justify="center") length_entry.pack(pady=5)
tk.Label(root, text="💵 Rate per Inch (Rs):", font=("Arial", 12), bg="#f0f0f0").pack(pady=5) rate_entry = tk.Entry(root, width=30, font=("Arial", 11), justify="center") rate_entry.pack(pady=5)
calc_btn = tk.Button(root, text="🧮 Calculate KAREIN", command=calculate, bg="#005bb5", fg="white", font=("Arial", 12, "bold"), width=20, height=2) calc_btn.pack(pady=15)