Bill Maker is a program that calculate the bill of a product just by inserting any product in it. It is efficient in making bills a bit faster and more arranged.
Modules used in Bill Maker :-
from tkinter import *
import xlsxwriter
from datetime import date
tkinter: It is used to create graphical user interface based application in python.
xlsxwriter: It is used to create Microsoft Excel files in python.
datetime: It is used for manipulating dates and times.
Firstly, just create a simple gray screen
if __name__ == '__main__':
root = Tk()
#cannot be resizable
root.resizable(0, 0)
#title of the application
root.title("BILL MAKER ver 1.0 @dx4iot")
root.config(background="gray10")
root.mainloop()
Output:
Now create some entry boxes and button for entering the necessary details like bill number, date, customer name, quantity of a product, etc.
#Heading of the project
enter_label = Label(root,text="BILL MAKER",font="Forte 20 bold",bg="gray10",fg="white",width=20)
enter_label.pack()
#entrybox bill number
enter_billNo = Entry(root,font="Forte 20 bold",width=20)
enter_billNo.insert(0,'Enter Bill No')
on_click_id = enter_billNo.bind('<Button-1>',onclick)
enter_billNo.pack()
#entrybox for date
enter_date = Entry(root,font="Forte 20 bold",width=20)
enter_date.insert(0,date.today())
enter_date.pack()
#fentrybox for customer name
enter_customerName = Entry(root,font="Forte 20 bold",width=20)
enter_customerName.insert(0,'Enter Customer Name')
on_click_id_1 = enter_customerName.bind('<Button-1>',onclick1)
enter_customerName.pack()
#entrybox for no of peices
enter_peices = Entry(root,font="Forte 20 bold",width=20)
enter_peices.insert(0,'Enter Pieces')
on_click_id_2 = enter_peices.bind('<Button-1>',onclick2)
enter_peices.pack()
#entrybox for quantity
enter_quan = Entry(root,font="Forte 20 bold",width=20)
enter_quan.insert(0,'Enter Quantity')
on_click_id_3 = enter_quan.bind('<Button-1>',onclick3)
enter_quan.pack()
#entrybox for name of product
enter_name = Entry(root,font="Forte 20 bold",width=20)
enter_name.insert(0,'Enter Name')
on_click_id_4 = enter_name.bind('<Button-1>',onclick4)
enter_name.pack()
#entrybox for price of a product
enter_prize = Entry(root,font="Forte 20 bold",width=20)
enter_prize.insert(0,'Enter Price')
on_click_id_5 = enter_prize.bind('<Button-1>',onclick5)
enter_prize.pack()
#insert button
button = Button(root, text='INSERT', command=getentryvalue,fg='white',font='Forte 20',bg="gray10",width=20)
button.pack(pady=10)
Output:
Now create a function getentryvalue()
for handling the data
from tkinter import *
import xlsxwriter
from datetime import date
append_name = []
append_quan = []
append_prize = []
append_prize = []
append_peices = []
def onclick(event):
enter_billNo.delete(0,END)
def onclick1(event):
enter_customerName.delete(0,END)
def onclick2(event):
enter_peices.delete(0,END)
def onclick3(event):
enter_quan.delete(0,END)
def onclick4(event):
enter_name.delete(0,END)
def onclick5(event):
enter_prize.delete(0,END)
def getentryvalue():
append_quan.append(enter_quan.get())
append_name.append(enter_name.get())
append_prize.append(enter_prize.get())
append_peices.append(enter_peices.get())
enter_quan.delete(0,END)
enter_name.delete(0,END)
enter_prize.delete(0,END)
enter_peices.delete(0,END)
enter_peices.insert(0,"Enter Peices")
enter_quan.insert(0,'Enter Quantity')
enter_name.insert(0,'Enter Name')
enter_prize.insert(0,"Enter Price")
new_file = f"{enter_billNo.get()}.{enter_customerName.get()}.xlsx"
excel_sheet = xlsxwriter.Workbook(new_file)
new_sheet = excel_sheet.add_worksheet()
tot_billNo = f"BILL NO: {enter_billNo.get()}"
tot_date = f"DATE: {enter_date.get()}"
enter_customerName.get()
new_sheet.write("B2",enter_customerName.get())
new_sheet.write("E1",tot_date)
new_sheet.write("E2",tot_billNo)
new_sheet.write("A4,","Pieces")
new_sheet.write("B4","Quantity")
new_sheet.write("C4","Names")
new_sheet.write("D4","Prize")
new_sheet.write("E4","Total")
for item in range(len(append_peices)):
item_pieces = int(append_peices[item])
new_sheet.write(item+4,0,item_pieces)
for item in range(len(append_quan)):
j = int(append_quan[item])
new_sheet.write(item+4,1, j)
for item in range(len(append_name)):
new_sheet.write(item+4,2,append_name[item])
for item in range(len(append_prize)):
i = float(append_prize[item])
new_sheet.write(item+4,3,i)
try:
val_i = 5
for item in range(len(append_quan)):
forMula = f"=A{val_i}*B{val_i}*D{val_i}"
new_sheet.write_formula(item+4,4,forMula)
val_i += 1
new_val_1 = val_i
finally:
new_val_2 = f"E{new_val_1+1}"
forMula_1 = f"=SUM(E5:E{str(new_val_1)})"
new_sheet.write_formula(new_val_2,forMula_1)
excel_sheet.close()
if __name__ == '__main__':
root = Tk()
root.iconbitmap('icon.ico')
root.resizable(0, 0)
root.title("BILL MAKER ver 1.0 @dx4iot")
root.config(background="gray10")
enter_label = Label(root,text="BILL MAKER",font="Forte 20 bold",bg="gray10",fg="white",width=20)
enter_label.pack()
enter_billNo = Entry(root,font="Forte 20 bold",width=20)
enter_billNo.insert(0,'Enter Bill No')
on_click_id = enter_billNo.bind('<Button-1>',onclick)
enter_billNo.pack()
enter_date = Entry(root,font="Forte 20 bold",width=20)
enter_date.insert(0,date.today())
enter_date.pack()
enter_customerName = Entry(root,font="Forte 20 bold",width=20)
enter_customerName.insert(0,'Enter Customer Name')
on_click_id_1 = enter_customerName.bind('<Button-1>',onclick1)
enter_customerName.pack()
enter_peices = Entry(root,font="Forte 20 bold",width=20)
enter_peices.insert(0,'Enter Pieces')
on_click_id_2 = enter_peices.bind('<Button-1>',onclick2)
enter_peices.pack()
enter_quan = Entry(root,font="Forte 20 bold",width=20)
enter_quan.insert(0,'Enter Quantity')
on_click_id_3 = enter_quan.bind('<Button-1>',onclick3)
enter_quan.pack()
enter_name = Entry(root,font="Forte 20 bold",width=20)
enter_name.insert(0,'Enter Name')
on_click_id_4 = enter_name.bind('<Button-1>',onclick4)
enter_name.pack()
enter_prize = Entry(root,font="Forte 20 bold",width=20)
enter_prize.insert(0,'Enter Price')
on_click_id_5 = enter_prize.bind('<Button-1>',onclick5)
enter_prize.pack()
button = Button(root, text='INSERT', command=getentryvalue,fg='white',font='Forte 20',bg="gray10",width=20)
button.pack(pady=10)
root.mainloop()
Now for testing let's insert some values Result: