from tkinter import * import pymysql root=Tk() root.geometry("800x500") view=Frame(root,height=300,width=800,relief=SOLID,borderwidth=2) view.pack(fill=X,expand=YES,padx=20,pady=20) conn = pymysql.connect(host='localhost', user='root', passwd='', db='python') cur=conn.cursor() rollh=Label(view,text="ROLL NO",width=10,borderwidth=4,relief=RIDGE,font=("Ariel 14 bold")) rollh.grid(row=0,column=0,ipady=3) nameh=Label(view,text="NAME",width=20,borderwidth=4,relief=RIDGE,font="Ariel 14 bold") nameh.grid(row=0,column=1,ipady=3) addrh=Label(view,text="ADDRESS",borderwidth=4,relief=RIDGE,font="Ariel 14 bold") addrh.grid(row=0,column=2,ipady=3,columnspan=2,sticky="ew") genh=Label(view,text="GENDER",width=10,borderwidth=4,relief=RIDGE,font="Ariel 14 bold") genh.grid(row=0,column=4,ipady=3) sql="SELECT * FROM student" cur.execute(sql) d=cur.fetchall() n=cur.rowcount r=1 for i in range(n): roll=Label(view,text=d[i][0],width=10,borderwidth=1,relief=SOLID) roll.grid(row=r,column=0,ipady=3,sticky="nsew") name=Label(view,text=d[i][1],width=20,borderwidth=1,relief=SOLID) name.grid(row=r,column=1,ipady=3,sticky="nsew") addr=Text(view,width=30,height=3,borderwidth=1,relief=SOLID,bg=root.cget('bg')) scrollb =Scrollbar(view, command=addr.yview,width=15) scrollb.grid(row=r, column=3, sticky="nsw") addr['yscrollcommand'] = scrollb.set addr.insert("1.0",d[i][2]) addr.configure(state="disabled") addr.grid(row=r,column=2,ipady=3,sticky="nsew") gen=Label(view,text=d[i][3],width=10,borderwidth=1,relief=SOLID) gen.grid(row=r,column=4,ipady=3,sticky="nsew") r=r+1 root.mainloop()