-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchData.py
73 lines (58 loc) · 2.64 KB
/
SearchData.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
import tkinter as tk
from tkinter import ttk
import mysql.connector as co
def SearchingData():
mycon = co.connect(
host='localhost',
user='root',
passwd='Sarvesh@27',
database='Shubham_Collection'
)
mycursor = mycon.cursor()
root = tk.Tk()
root.title("SEARCH PRODUCT")
root.geometry("1920x1080")
def search():
ColumnType = entry1.get()
query = entry2.get()
mycursor.execute(f"SELECT * FROM Product_Details WHERE {ColumnType} = '{query}'")
result = mycursor.fetchall()
if result:
error_label.config(text="Product Found", fg='green')
for i in tree.get_children():
tree.delete(i)
for row in result:
tree.insert("", "end", values=row)
else:
error_label.config(text="Product Not Found", fg='red')
for i in tree.get_children():
tree.delete(i)
label1 = tk.Label(root, text="SEARCH DATA", font=('Arial', 35, 'bold'), fg='red')
label1.pack()
label2 = tk.Label(root, text="Search By: ", font=('Arial', 18, 'bold'), fg='red')
label2.place(x=370, y=80)
s = ttk.Style(root)
s.theme_use("clam")
s.configure("Treeview", background="lightblue", foreground='black', fieldbackground='lightblue', rowheight=25)
s.configure(".", font=('Arial', 10, 'bold'))
s.configure("Treeview.Heading", font=('Arial', 10, 'bold'), foreground='red', background='#FFFDD0')
entry1 = ttk.Entry(root, width=30)
entry1.place(x=500, y=90)
entry2 = ttk.Entry(root, width=30)
entry2.place(x=900, y=90)
error_label = tk.Label(root, text="", font=('Arial', 12), fg='red')
error_label.pack(pady=10)
search_button = ttk.Button(root, text="SEARCH PRODUCT", command=search)
search_button.pack(pady=70)
tree = ttk.Treeview(root, columns=("Brand", "Garment_Type", "Product_Code", "Size", "Colour", "Quantity", "MRP"), show="headings")
tree.heading("Brand", text="Brand", anchor=tk.CENTER)
tree.heading("Garment_Type", text="Garment_Type", anchor=tk.CENTER)
tree.heading("Product_Code", text="Product_Code", anchor=tk.CENTER)
tree.heading("Size", text="Size", anchor=tk.CENTER)
tree.heading("Colour", text="Colour", anchor=tk.CENTER)
tree.heading("Quantity", text="Quantity", anchor=tk.CENTER)
tree.heading("MRP", text="MRP", anchor=tk.CENTER)
for col in ("Brand", "Garment_Type", "Product_Code", "Size", "Colour", "Quantity", "MRP"):
tree.column(col, anchor=tk.CENTER)
tree.pack(expand=True, fill="both")
root.mainloop()