|
1 | 1 | from tkinter import * |
2 | | -from PIL import ImageTk,Image |
3 | | -import pymysql |
4 | | -from tkinter import messagebox,ttk |
| 2 | +import PIL.Image, PIL.ImageTk |
5 | 3 |
|
6 | 4 | from modules.AddBook import * |
7 | 5 | from modules.DeleteBook import * |
8 | 6 | from modules.ViewBooks import * |
9 | 7 | from modules.Sounds import click |
10 | 8 | from modules.IssueBook import * |
11 | 9 | from modules.ReturnBook import * |
12 | | - |
13 | | -root = Tk() |
14 | | - |
15 | | -root.title("Library Manager AVBIL") |
16 | | -root.minsize(848, 480) |
17 | | -root.iconbitmap("media\logo.ico") |
18 | | - |
19 | | - |
20 | | -img = ImageTk.PhotoImage(Image.open("media\lib.png")) |
21 | | -Canvas = Canvas(root, width = 960, height = 540) |
22 | | -Canvas.pack(fill = BOTH, expand = True) |
23 | | -Canvas.create_image(0,0,image = img, anchor="nw") |
24 | | - |
25 | | -headingFrame1 = Frame(root, bg = "#2F2F87", bd = 5) |
26 | | -headingFrame1.place(relx = 0.2, rely = 0.1, relwidth = 0.6, relheight = 0.16) |
27 | | -headingLabel = Label(headingFrame1, text="AVBIL Library Manager", bg='#121212', fg='white', font=('Segoe UI',30)) |
28 | | -headingLabel.place(relx = 0, rely = 0, relwidth = 1, relheight =1) |
29 | | - |
30 | | -status_label = Label(root, text = "Made by Lakshyajeet Jalal and Sagar Giri ", bg = "#121212", fg = "white", relief = SUNKEN, font = ('Segoe UI',10), anchor = E) |
31 | | -status_label.pack(fill = X, side = BOTTOM, ipady = 2) |
32 | | - |
33 | | -#Button 1 |
34 | | -btn1 = Button(root, text = "Add Book", bg = '#121212', fg = 'white', font=('Segoe UI',20), command = lambda:[click(),add_open(),addBook()]) |
35 | | -btn1.place(relx = 0.28, rely = 0.4, relwidth = 0.45, relheight = 0.09) |
36 | | - |
37 | | -def btn1_hoverin(event): |
38 | | - btn1["bg"] = "#222222" |
39 | | - btn1["font"]= 'Segoe UI',22 |
40 | | - status_label.config(text = "Click To Add Book ") |
41 | | - |
42 | | -def btn1_hoverout(event): |
43 | | - btn1["bg"] = "#121212" |
44 | | - btn1["font"]= 'Segoe UI',20 |
45 | | - status_label.config(text = "Made by Lakshyajeet Jalal and Sagar Giri ") |
46 | | - |
47 | | -btn1.bind("<Enter>", btn1_hoverin) |
48 | | -btn1.bind("<Leave>", btn1_hoverout) |
49 | | - |
50 | | -#Button 2 |
51 | | -btn2 = Button(root, text= "Delete Book", bg = '#121212', fg = 'white', font=('Segoe UI',20), command = lambda:[click(), del_open(),delete()]) |
52 | | -btn2.place(relx = 0.28, rely = 0.5, relwidth = 0.45, relheight = 0.09) |
53 | | - |
54 | | -def btn2_hoverin(event): |
55 | | - btn2["bg"] = "#222222" |
56 | | - btn2["font"]= 'Segoe UI',22 |
57 | | - status_label.config(text = "Click To Delete Book ") |
58 | | - |
59 | | -def btn2_hoverout(event): |
60 | | - btn2["bg"] = "#121212" |
61 | | - btn2["font"]= 'Segoe UI',20 |
62 | | - status_label.config(text = "Made by Lakshyajeet Jalal and Sagar Giri ") |
63 | | - |
64 | | -btn2.bind("<Enter>", btn2_hoverin) |
65 | | -btn2.bind("<Leave>", btn2_hoverout) |
66 | | - |
67 | | -#Button 3 |
68 | | -btn3 = Button(root, text= "View Book List", bg = '#121212', fg = 'white', font=('Segoe UI',20), command = lambda:[click(), view_open(), View()]) |
69 | | -btn3.place(relx = 0.28, rely= 0.6, relwidth = 0.45,relheight = 0.09) |
70 | | - |
71 | | -def btn3_hoverin(event): |
72 | | - btn3["bg"] = "#222222" |
73 | | - btn3["font"]= 'Segoe UI',22 |
74 | | - status_label.config(text = "Click To View Book List ") |
75 | | - |
76 | | -def btn3_hoverout(event): |
77 | | - btn3["bg"] = "#121212" |
78 | | - btn3["font"]= 'Segoe UI',20 |
79 | | - status_label.config(text = "Made by Lakshyajeet Jalal and Sagar Giri ") |
80 | | - |
81 | | -btn3.bind("<Enter>", btn3_hoverin) |
82 | | -btn3.bind("<Leave>", btn3_hoverout) |
83 | | - |
84 | | -#Button 4 |
85 | | -btn4 = Button(root, text= "Issue Book", bg = '#121212', fg = 'white', font=('Segoe UI',20), command = lambda:[click(), issue_open(), issueBook()]) |
86 | | -btn4.place(relx = 0.28, rely= 0.7, relwidth = 0.45,relheight = 0.09) |
87 | | - |
88 | | -def btn4_hoverin(event): |
89 | | - btn4["bg"] = "#222222" |
90 | | - btn4["font"]= 'Segoe UI',22 |
91 | | - status_label.config(text = "Click To Issue Book ") |
92 | | - |
93 | | -def btn4_hoverout(event): |
94 | | - btn4["bg"] = "#121212" |
95 | | - btn4["font"]= 'Segoe UI',20 |
96 | | - status_label.config(text = "Made by Lakshyajeet Jalal and Sagar Giri ") |
97 | | - |
98 | | -btn4.bind("<Enter>", btn4_hoverin) |
99 | | -btn4.bind("<Leave>", btn4_hoverout) |
100 | | - |
101 | | -#Button 5 |
102 | | -btn5 = Button(root, text= "Return Book", bg= '#121212', fg = 'white', font=('Segoe UI',20), command = lambda:[click(), rtn_open(), returnBook()]) |
103 | | -btn5.place(relx = 0.28, rely= 0.8, relwidth = 0.45,relheight = 0.09) |
104 | | - |
105 | | -def btn5_hoverin(event): |
106 | | - btn5["bg"] = "#222222" |
107 | | - btn5["font"]= 'Segoe UI',22 |
108 | | - status_label.config(text = "Click To Return Book ") |
109 | | - |
110 | | -def btn5_hoverout(event): |
111 | | - btn5["bg"] = "#121212" |
112 | | - btn5["font"]= 'Segoe UI',20 |
113 | | - status_label.config(text = "Made by Lakshyajeet Jalal and Sagar Giri ") |
114 | | - |
115 | | -btn5.bind("<Enter>", btn5_hoverin) |
116 | | -btn5.bind("<Leave>", btn5_hoverout) |
117 | | - |
118 | | -root.mainloop() |
| 10 | +from modules.Credentials import * |
| 11 | + |
| 12 | +if check_cred(): |
| 13 | + |
| 14 | + # Check clear |
| 15 | + add_close() |
| 16 | + del_close() |
| 17 | + issue_close() |
| 18 | + rtn_close() |
| 19 | + view_close() |
| 20 | + |
| 21 | + root = Tk() |
| 22 | + |
| 23 | + root.title("Library Manager AVBIL") |
| 24 | + root.minsize(848, 480) |
| 25 | + root.iconbitmap("media\logo.ico") |
| 26 | + |
| 27 | + img = PIL.ImageTk.PhotoImage(PIL.Image.open("media\lib.png")) |
| 28 | + Canvas = Canvas(root, width=960, height=540) |
| 29 | + Canvas.pack(fill=BOTH, expand=True) |
| 30 | + Canvas.create_image(0, 0, image=img, anchor="nw") |
| 31 | + |
| 32 | + # Heading Frame |
| 33 | + headingFrame1 = Frame(root, bg="#2F2F87", bd=5) |
| 34 | + headingFrame1.place(relx=0.2, rely=0.1, relwidth=0.6, relheight=0.16) |
| 35 | + |
| 36 | + # Heading Label |
| 37 | + headingLabel = Label( |
| 38 | + headingFrame1, |
| 39 | + text="AVBIL Library Manager", |
| 40 | + bg="#121212", |
| 41 | + fg="white", |
| 42 | + font=("Segoe UI", 30), |
| 43 | + ) |
| 44 | + headingLabel.place(relx=0, rely=0, relwidth=1, relheight=1) |
| 45 | + |
| 46 | + # Status Label |
| 47 | + status_label = Label( |
| 48 | + root, |
| 49 | + text="Made by Lakshyajeet Jalal and Sagar Giri ", |
| 50 | + bg="#121212", |
| 51 | + fg="white", |
| 52 | + relief=SUNKEN, |
| 53 | + font=("Segoe UI", 10), |
| 54 | + anchor=E, |
| 55 | + ) |
| 56 | + status_label.pack(fill=X, side=BOTTOM, ipady=2) |
| 57 | + |
| 58 | + # Status Label reset |
| 59 | + def status_label_rst(): |
| 60 | + status_label.config(text="Made by Lakshyajeet Jalal and Sagar Giri ") |
| 61 | + |
| 62 | + # addBook Button |
| 63 | + addBookBtn = Button( |
| 64 | + root, |
| 65 | + text="Add Book", |
| 66 | + bg="#121212", |
| 67 | + fg="white", |
| 68 | + font=("Segoe UI", 20), |
| 69 | + command=lambda: [click(), add_open(), addBookWin()], |
| 70 | + ) |
| 71 | + addBookBtn.place(relx=0.28, rely=0.4, relwidth=0.45, relheight=0.09) |
| 72 | + |
| 73 | + def addBookBtn_hoverin(event): |
| 74 | + addBookBtn["bg"] = "#222222" |
| 75 | + addBookBtn["font"] = "Segoe UI", 22 |
| 76 | + status_label.config(text="Click To Add Book ") |
| 77 | + |
| 78 | + def addBookBtn_hoverout(event): |
| 79 | + addBookBtn["bg"] = "#121212" |
| 80 | + addBookBtn["font"] = "Segoe UI", 20 |
| 81 | + status_label_rst() |
| 82 | + |
| 83 | + addBookBtn.bind("<Enter>", addBookBtn_hoverin) |
| 84 | + addBookBtn.bind("<Leave>", addBookBtn_hoverout) |
| 85 | + |
| 86 | + # delBook Button |
| 87 | + delBookBtn = Button( |
| 88 | + root, |
| 89 | + text="Delete Book", |
| 90 | + bg="#121212", |
| 91 | + fg="white", |
| 92 | + font=("Segoe UI", 20), |
| 93 | + command=lambda: [click(), del_open(), deleteBookWin()], |
| 94 | + ) |
| 95 | + delBookBtn.place(relx=0.28, rely=0.5, relwidth=0.45, relheight=0.09) |
| 96 | + |
| 97 | + def delBookBtn_hoverin(event): |
| 98 | + delBookBtn["bg"] = "#222222" |
| 99 | + delBookBtn["font"] = "Segoe UI", 22 |
| 100 | + status_label.config(text="Click To Delete Book ") |
| 101 | + |
| 102 | + def delBookBtn_hoverout(event): |
| 103 | + delBookBtn["bg"] = "#121212" |
| 104 | + delBookBtn["font"] = "Segoe UI", 20 |
| 105 | + status_label_rst() |
| 106 | + |
| 107 | + delBookBtn.bind("<Enter>", delBookBtn_hoverin) |
| 108 | + delBookBtn.bind("<Leave>", delBookBtn_hoverout) |
| 109 | + |
| 110 | + # viewBook Button |
| 111 | + viewBookBtn = Button( |
| 112 | + root, |
| 113 | + text="View Book List", |
| 114 | + bg="#121212", |
| 115 | + fg="white", |
| 116 | + font=("Segoe UI", 20), |
| 117 | + command=lambda: [click(), view_open(), View()], |
| 118 | + ) |
| 119 | + viewBookBtn.place(relx=0.28, rely=0.6, relwidth=0.45, relheight=0.09) |
| 120 | + |
| 121 | + def viewBookBtn_hoverin(event): |
| 122 | + viewBookBtn["bg"] = "#222222" |
| 123 | + viewBookBtn["font"] = "Segoe UI", 22 |
| 124 | + status_label.config(text="Click To View Book List ") |
| 125 | + |
| 126 | + def viewBookBtn_hoverout(event): |
| 127 | + viewBookBtn["bg"] = "#121212" |
| 128 | + viewBookBtn["font"] = "Segoe UI", 20 |
| 129 | + status_label_rst() |
| 130 | + |
| 131 | + viewBookBtn.bind("<Enter>", viewBookBtn_hoverin) |
| 132 | + viewBookBtn.bind("<Leave>", viewBookBtn_hoverout) |
| 133 | + |
| 134 | + # issueBook Button |
| 135 | + issueBookBtn = Button( |
| 136 | + root, |
| 137 | + text="Issue Book", |
| 138 | + bg="#121212", |
| 139 | + fg="white", |
| 140 | + font=("Segoe UI", 20), |
| 141 | + command=lambda: [click(), issue_open(), issueBook()], |
| 142 | + ) |
| 143 | + issueBookBtn.place(relx=0.28, rely=0.7, relwidth=0.45, relheight=0.09) |
| 144 | + |
| 145 | + def issueBookBtn_hoverin(event): |
| 146 | + issueBookBtn["bg"] = "#222222" |
| 147 | + issueBookBtn["font"] = "Segoe UI", 22 |
| 148 | + status_label.config(text="Click To Issue Book ") |
| 149 | + |
| 150 | + def issueBookBtn_hoverout(event): |
| 151 | + issueBookBtn["bg"] = "#121212" |
| 152 | + issueBookBtn["font"] = "Segoe UI", 20 |
| 153 | + status_label_rst() |
| 154 | + |
| 155 | + issueBookBtn.bind("<Enter>", issueBookBtn_hoverin) |
| 156 | + issueBookBtn.bind("<Leave>", issueBookBtn_hoverout) |
| 157 | + |
| 158 | + # returnBook Button |
| 159 | + returnBookBtn = Button( |
| 160 | + root, |
| 161 | + text="Return Book", |
| 162 | + bg="#121212", |
| 163 | + fg="white", |
| 164 | + font=("Segoe UI", 20), |
| 165 | + command=lambda: [click(), rtn_open(), returnBook()], |
| 166 | + ) |
| 167 | + returnBookBtn.place(relx=0.28, rely=0.8, relwidth=0.45, relheight=0.09) |
| 168 | + |
| 169 | + def returnBookBtn_hoverin(event): |
| 170 | + returnBookBtn["bg"] = "#222222" |
| 171 | + returnBookBtn["font"] = "Segoe UI", 22 |
| 172 | + status_label.config(text="Click To Return Book ") |
| 173 | + |
| 174 | + def returnBookBtn_hoverout(event): |
| 175 | + returnBookBtn["bg"] = "#121212" |
| 176 | + returnBookBtn["font"] = "Segoe UI", 20 |
| 177 | + status_label_rst() |
| 178 | + |
| 179 | + returnBookBtn.bind("<Enter>", returnBookBtn_hoverin) |
| 180 | + returnBookBtn.bind("<Leave>", returnBookBtn_hoverout) |
| 181 | + |
| 182 | + def confirm(): |
| 183 | + if messagebox.askyesno(title="Confirm", message="Are you sure that you want to quit?"): |
| 184 | + root.destroy() |
| 185 | + |
| 186 | + root.protocol("WM_DELETE_WINDOW", lambda: [click(), confirm()]) |
| 187 | + root.mainloop() |
0 commit comments