-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewbook.py
45 lines (41 loc) · 1.76 KB
/
viewbook.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
from tkinter import *
from PIL import ImageTk,Image
from tkinter import messagebox
import pymysql
mypass="root"
mydatabase="db"
con=pymysql.connect(host="localhost",user="root",password=mypass,database=mydatabase)
cur=con.cursor()
booktable="books"
def view():
root=Tk()
root.title("Library")
root.minsize(width=400,height=400)
root.geometry("600x500")
Canvas1=Canvas(root)
Canvas1.config(bg="#12a4d9")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1=Frame(root,bg="#FFBB00",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13)
headinglable1=Label(headingFrame1,text="View BOOks",bg='black',fg='white',font=('Courier',15))
headinglable1.place(relx=0,rely=0,relwidth=1,relheight=1)
labelFrame = Frame(root, bg='black')
labelFrame.place(relx=0.1, rely=0.3, relwidth=0.8, relheight=0.5)
y = 0.25
Label(labelFrame, text="%-10s%-40s%-30s%-20s" % ('BID', 'Title', 'Author', 'Status'),
bg='black', fg='white').place(relx=0.07, rely=0.1)
Label(labelFrame, text="---------------------------------------------------------------------------------", bg='black',
fg='white').place(relx=0.05, rely=0.2)
getBooks = "select * from " + booktable
try:
cur.execute(getBooks)
con.commit()
for i in cur:
Label(labelFrame, text="%-10s%-40s%-30s%-20s" % (i[0], i[1], i[2], i[3]), bg='black', fg='white').place(
relx=0.07, rely=y)
y += 0.1
except:
messagebox.showinfo("Failed to fetch files from database")
quitBtn = Button(root, text="Quit", bg='#f7f1e3', fg='black', command=root.destroy)
quitBtn.place(relx=0.4, rely=0.9, relwidth=0.18, relheight=0.08)
root.mainloop()