-
Notifications
You must be signed in to change notification settings - Fork 2
/
sales.py
127 lines (86 loc) · 4.62 KB
/
sales.py
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from tkinter import*
from PIL import Image, ImageTk
import sqlite3
from tkinter import ttk ,messagebox
import os
class salesClass:
def __init__ (self,root):
self.root=root
self.root.geometry("1073x523+200+123")
self.root.title("Shopping Managment System | Developed by Team 3")
self.root.config(bg='white')
self.root.focus_force()
self.bill_list=[]
self.var_invoice=StringVar()
#title=======
lbl_title=Label(self.root,text="View Customer Bill ",font=("goudy old style",30),bg="#184a45",fg="white").pack(side=TOP,fill=X,padx=10,pady=20)
lbl_invoice=Label(self.root,text="Invoice No.",font=("times new roman",15),bg="white").place(x=50,y=100)
txt_invoice=Entry(self.root,textvariable=self.var_invoice,font=("times new roman",15),bg="lightyellow").place(x=160,y=100,width=180,height=28)
btn_search=Button(self.root,text="Search",command=self.search, font=("times new roman", 15, "bold"),bg="#2196f3",fg="white",cursor="hand2").place(x=360,y=100,width=120,height=28)
btn_clear=Button(self.root,text="clear",command=self.clear ,font=("times new roman", 15, "bold"),bg="lightgray",cursor="hand2").place(x=490,y=100,width=120,height=28)
sales_Frame=Frame(self.root,bd=3,relief=RIDGE)
sales_Frame.place(x=50,y=140,width=200,height=330)
#===Bill List===
scrolly=Scrollbar(sales_Frame, orient=VERTICAL)
self.Sales_List=Listbox(sales_Frame,font=("goudy old style",15),bg="white",yscrollcommand=scrolly.set)
self.Sales_List.pack(fill=BOTH,expand=1)
sales_Frame.place(x=50,y=140, width=200,height=330)
self.bill_area=Listbox(sales_Frame, font=("goudy old style",15),bg="white",yscrollcommand=scrolly.set)
scrolly.pack(side=RIGHT, fill=Y)
scrolly.config(command=self.Sales_List.yview)
self.bill_area.pack(fill=BOTH, expand=1)
self.Sales_List.bind("<ButtonRelease-1>",self.get_data)
#===Bill Area===
bill_Frame=Frame(self.root, bd=3,relief=RIDGE)
bill_Frame.place (x=280,y=140, width=410,height=330)
lbl_title2=Label(bill_Frame,text="Customer Bill Area",font=("goudy old style",20),bg="orange").pack(side=TOP,fill=X)
scrolly2=Scrollbar(sales_Frame, orient=VERTICAL)
self.bill_area=Text(bill_Frame, font=("goudy old style",15),bg="lightyellow",yscrollcommand=scrolly2.set)
scrolly2.pack(side=RIGHT, fill=Y)
scrolly2.config(command=self.bill_area.yview)
self.bill_area.pack(fill=BOTH, expand=1)
#====Image========
self.bill_photo=Image.open("images/cat2.jpg")
self.bill_photo = self.bill_photo.resize((450, 300), Image.BOX)
self.bill_photo=ImageTk.PhotoImage(self.bill_photo)
lbl_image=Label(self.root,image=self.bill_photo,bd=0)
lbl_image.place(x=690,y=150)
self.show()
#=====================================================================
def show(self):
self.bill_list[:]
self.Sales_List.delete(0, END)
# print(os.listdir('../IMS')) bill1.txt, category.py
for i in os.listdir('bill'):
# print(i.split('.'),i.split('.')[-1])
if i.split('.')[-1]=='txt':
self.Sales_List.insert(END,i)
self.bill_list.append(i.split('.')[0])
def get_data(self,ev):
index_=self.Sales_List.curselection()
file_name=self.Sales_List.get(index_)
print(file_name)
self.bill_area.delete('1.0',END)
fp=open(f'bill/{file_name}','r')
for i in fp:
self.bill_area.insert(END,i)
fp.close()
def search(self):
if self.var_invoice.get()=="":
messagebox.showerror("Error","Invoice no. should be required",parent=self.root)
else:
if self.var_invoice.get() in self.bill_list:
fp=open(f'bill/{self.var_invoice.get()}.txt','r')
self.bill_area.delete('1.0', END)
for i in fp:
self.bill_area.insert(END,i)
fp.close()
else:
messagebox.showerror("Error","Invalid invoice no. ",parent=self.root)
def clear(self):
self.show()
self.bill_area.delete('1.0',END)
if __name__=='__main__':
root=Tk()
obj=salesClass(root)
root.mainloop()