-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbilling.py
More file actions
100 lines (71 loc) · 2.89 KB
/
billing.py
File metadata and controls
100 lines (71 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# mujhe ak billing software banan hai with the help of python & tkinter ak fresher level ka attractive jis mai discount ka option or gst ka option bhi ho ky tum mujhe stp by step explain karte hue batao ge?
"""
Entry → Tkinter ka ek widget hota hai
👉 jisme user typing karke input deta hai (textbox)
root → main window jisme ye textbox dikhai dega
discount_entry → ek variable name
👉 jisme hum is textbox ko store kar rahe hain
"""
'''
🔶 1. Tkinter kya hota hai?
Tkinter Python ka built-in GUI (Graphical User Interface) toolkit hai.
Isse aap windows, buttons, text boxes, labels, forms sab bana sakte ho —
jaise desktop software banta hai.
'''
from tkinter import *
# 1. Window Set-Up
root = Tk() # main window
root.title("Welcome to Billing Software") # Title Software name
root.geometry("400x500")
root.config(bg="#5E91F7")
# 2. Text & Entry Boxes [user Input fields]
# Items Label
Label(root, text="Items Name", bg="lightblue").pack()
item_entry = Entry(root)
item_entry.pack()
# Qty Label
Label(root, text="Quantity", bg="lightblue").pack()
quantity_entry = Entry(root)
quantity_entry.pack()
# price Label
Label(root, text="Price", bg="lightblue").pack()
price_entry = Entry(root)
price_entry.pack()
# Discount Label
Label(root, text="Discount", bg="lightblue").pack()
discount_price = Entry(root)
discount_price.pack()
# GST Label
Label(root, text="GST", bg="lightblue").pack()
gst_discount = Entry(root)
gst_discount.pack()
# 3. Billing calculation logic
def calculate_bill():
quantity = int(quantity_entry.get())
price = float(price_entry.get())
gst = float(gst_discount.get())
discount = float(discount_price.get())
total = quantity * price # 2 items * 100 = 200
discount_amount = total * discount / 100 # 200 ka 10% = 20
total_after_discount = total - discount_amount # 200 - 20 = 180
gst_amount = total_after_discount * gst / 100 # 180 ka 18% = 32.4
final_bill = total_after_discount + gst_amount # 180 + 32.4 = 212.4
result_label.config(text=f"Total Bill Is : {final_bill:.2f}")
# 4. Buttons & Output Labels
Button(root, text="Calculate Bill", command=calculate_bill, bg="green", fg="white").pack(pady=12)
result_label = Label(root, text="", bg="#5E91F7", font=("Arial", 12, "bold"))
result_label.pack()
def clear_data():
item_entry.delete(0, END)
quantity_entry.delete(0, END)
price_entry.delete(0, END)
discount_price.delete(0, END)
gst_discount.delete(0, END)
result_label.config(text='')
Button(root, text="clear", command=clear_data, bg="red", fg="white").pack(pady=5)
def backspace():
widget = root.focus_get()
if isinstance(widget, Entry):
widget.delete(len(widget.get()) - 1, END)
Button(root, text="Backspace", command=backspace, bg='orange').pack(pady=5)
mainloop() # Window ko run karta hai