Show
Show
# Add your own database name and password here to reflect in the code
db="car"
con =
sql.connect(host="localhost",user="root",password='12345',database=db)
def Display():
root = Tk()
root.title("Bike")
root.minsize(width=600,height=500)
root.geometry("600x500")
Canvas1 = Canvas(root)
Canvas1.config(bg="#F39308")
Canvas1.pack(expand=True,fill=BOTH)
headingFrame1 = Frame(root,bg="white",bd=5)
headingFrame1.place(relx=0.25,rely=0.1,relwidth=0.5,relheight=0.13)
labelFrame = Frame(root,bg='black')
labelFrame.place(relx=0.1,rely=0.3,relwidth=0.8,relheight=0.6)
y = 0.25
Label(labelFrame, text="%-10s%-20s%-30s%-30s%-30s%-20s%-20s%-20s%-
20s%-20s%-20s%-10s"%('C-id','f-name','L-Name','ID','IdNo','mno','C-
Model','C-Name','Colour','C-type','F-type','C-
price'),bg='black',fg='white').place(relx=0.07,rely=0.1)
Label(labelFrame, text="
",bg='black',fg='white').place(relx=0.07,rely=0.2)
cur = con.cursor()
getBooks = "select * from bike1"
try:
cur.execute(getBooks)
data=cur.fetchall()
con.commit()
for i in data:
Label(labelFrame, text="%-10s%-20s%-20s%-20s%-20s%-20s%-20s%-
20s%-20s%-20s%-20s%-
10s"%(i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9],i[10],i[11]),bg='
black',fg='white').place(relx=0.07,rely=y)
21
y += 0.1
except:
messagebox.showinfo("Failed to fetch files from database")
root.mainloop()
22