Jovian
⭐️
Sign In
In [79]:
#STUDENT DATABASE MANAGEMENT MINOR PROJECT

import tkinter as tk
from tkinter import *
import sqlite3 as sq
import tkinter.messagebox
from tkinter.filedialog import askopenfile
from tkinter import ttk
from PIL import Image, ImageTk
from tkcalendar import *

class SampleApp(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self._frame = None
        self.switch_frame(StartPage)
        self.geometry("1600x1000+0+0")
        self.configure(bg="cadet blue")
    def switch_frame(self,frame_class):
        new_frame=frame_class(self)
        if self._frame is not None:
            self._frame.destroy()
        self._frame=new_frame
        self._frame.pack()
class StartPage(tk.Frame):
    
    
    def __init__(self,master):
        tk.Frame.__init__(self,master)
        tk.Label(self,text="",width=30,height=20,bg="#5CDB95",font=("Vineta BT",20,"bold","italic","underline")).pack(side=TOP)
        tk.label0=tk.Label(self,text="Studet Database Management",width=30,height=2,fg='#05386B',bg="#5CDB95",font=("Vineta BT",20,"bold","italic","underline"))
        tk.label0.place(relx=0.0,rely=0.0)
  
        b1=tk.Button(self,text="Add Record",command=lambda: master.switch_frame(PageOne) )
        b1.place(relx=0.3,rely=0.5,relwidth=0.2)
        b2=tk.Button(self,text="View Record",command=lambda: master.switch_frame(PageTwo) )
        b2.place(relx=0.5,rely=0.5,relwidth=0.2)
        b3=tk.Button(self,text="Delete Record",command=lambda: master.switch_frame(PageThree) )
        b3.place(relx=0.3,rely=0.6,relwidth=0.2)
        b4=tk.Button(self,text="Update Record",command=lambda: master.switch_frame(PageFour) )
        b4.place(relx=0.5,rely=0.6,relwidth=0.2)
        b5=tk.Button(self,text="Search record",command=lambda: master.switch_frame(PageFive) )
        b5.place(relx=0.3,rely=0.7,relwidth=0.2)
        b6=tk.Button(self, text="Quit App", command=master.destroy)
        b6.place(relx=0.5,rely=0.7,relwidth=0.2)
        b1.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b2.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b3.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b4.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b5.config(cursor='mouse',bg='navy', fg='white', bd=8)
        b6.config(cursor='mouse',bg='navy', fg='white', bd=8)
        def imgview(self):
            self.img  = Image.open("trident.jpg")
            self.img = self.img.resize((820,250)) 
            photo=ImageTk.PhotoImage(self.img)
            self.lab=Label(self,image=photo)    
            self.img.image=photo
            self.lab.place(relx=0.02,rely=0.12)
        return imgview(self)
        
class PageOne(tk.Frame):
    
    
    def __init__ (self,master):
        tk.Frame.__init__(self,master)
        tk.Frame.configure(self,bg='PeachPuff')
        #self.title("Entry Form")
        label=tk.Label(self,text=" ",bd=12,width=70,height=35,bg="lawngreen",fg="blue",font=("times",12,"bold","italic")).pack()
        
        label0=tk.Label(self,text="Add Student Records Here",fg='#05386B',bg="lawngreen",pady=4,width=50,)
        label0.place(relx=0.0,rely=0.0)
        label0.config(font=("Vineta BT",10,"bold","italic"))
        


        e1 = tk.StringVar(self)
        e2 = tk.StringVar(self)
        e3 = tk.IntVar(self,'')
        e4 = tk.IntVar(self,'')
        de1=tk.StringVar(self,'')
        r1 = tk.StringVar(self,'')
        d=tk.StringVar(self)
        
        
        self.label1=tk.Label(self,text="Student Name*",width=20)
        self.label1.place(relx=0.1,rely=0.08)
        self.nentry=tk.Entry(self,textvariable=e1)
        self.nentry.place(relx=0.5,rely=0.08,relwidth=0.3)
        
        self.lbl2=tk.Label(self,text="DOB*",width=20)
        self.lbl2.place(relx=0.1,rely=0.14)
        self.ent=DateEntry(self,backgroundcolor="blue",foreground="red",borderwidth=15,textvariable=de1)
        self.ent.place(relx=0.5,rely=0.14,relwidth=0.3)
        
        self.label2=tk.Label(self,text="Father's Name*",width=20)
        self.label2.place(relx=0.1,rely=0.21)
        self.fentry=tk.Entry(self,textvariable=e2)
        self.fentry.place(relx=0.5,rely=0.21,relwidth=0.3)
        
        self.label3=tk.Label(self,text="Age*",width=20)
        self.label3.place(relx=0.1,rely=0.3)
        self.aentry=tk.Entry(self,textvariable=e3)
        self.aentry.place(relx=0.5,rely=0.3,relwidth=0.3)
        
        self.label4=tk.Label(self,text="Student ID*",width=20)
        self.label4.place(relx=0.1,rely=0.4)
        self.identry=tk.Entry(self,textvariable=e4)
        self.identry.place(relx=0.5,rely=0.4,relwidth=0.3)
        
        self.label4=tk.Label(self,text="Gender*",width=20)
        self.label4.place(relx=0.1,rely=0.5)
        
        self.radiobutton1=tk.Radiobutton(self,text="male",value='male',var=r1).place(relx=0.5,rely=0.5)
        self.radiobutton2=tk.Radiobutton(self,text="Female",value='female',var=r1).place(relx=0.7,rely=0.5)
        
        self.label4=tk.Label(self,text="Country*",width=20)
        self.label4.place(relx=0.1,rely=0.6)
        
        list1 = ['Canada','India','UK','Nepal','Iceland','South Africa'];
        self.droplist=OptionMenu(self,d, *list1)
        self.droplist.config(width=15)
        d.set('select your country') 
        self.droplist.place(relx=0.5,rely=0.6,width=200)
        
        
        self.label5=tk.Label(self,text="Upload Your Photo",width=20)
        self.label5.place(relx=0.1,rely=0.7)
        btn1 = Button(self, text ='import', width=15, command = lambda:OpenFile(self))
        btn1.place(relx=0.5,rely=0.7)
        btn1.config(cursor='mouse',bg='navajoWhite4', fg='white', bd=3)
        def create(self):
            print("You have submitted a record")
            if e1.get() == "":
                tkinter.messagebox.showinfo("Warning", "Please Enter Your Name")
                #if e1.get()==is_integer():
                #if assert type(e1.get) == int:
#                 def entryValidate(self, *args):
#                     if self.e1.get().isalpha():
#                         tkinter.messagebox.showinfo("Warning", "Please Enter only Character")
#                 return entryValidate()
            elif e2.get() == "":
                tkinter.messagebox.showinfo("Warning", "Please Enter Your Fathers Name")
            elif e3.get() == "":
                tkinter.messagebox.showinfo("Warning", "Please Enter Your Age")
            elif e4.get() == "":
                tkinter.messagebox.showinfo("Warning", "Please Enter Your Roll Num")
            elif de1.get() =="":
                tkinter.messagebox.showinfo("Warning", "Please Enter DOB")
            else:
                try:
                    c.execute('CREATE TABLE IF NOT EXISTS stud(name TEXT UNIQUe,fname TEXT UNIQUE,age INTEGER,roll INTEGER UNIQUE,gender TEXT,country TEXT,dob DATESTAMP)') 
                    c.execute('INSERT INTO stud(name,fname,age,roll,gender,country,dob) VALUES(?, ?, ?, ?, ?, ?,?)',[e1.get(),e2.get(),e3.get(),e4.get(),r1.get(),d.get(),de1.get()])
                    result=tkinter.messagebox.askyesno("submit","Do you want to submit ?")
                    if result==True:
                        tkinter.messagebox.showinfo("record  submitted","Your data submitted successfully")
                except:
                    tkinter.messagebox.showinfo("wrong input", "Please don't repeat your record!!its already present")
            con.commit()
        def clearData(self):
            self.nentry.delete(0,END)
            self.fentry.delete(0,END)
            self.aentry.delete(0,END)
            self.identry.delete(0,END)
            self.ent.delete(0,END)
            d.set('Select Your Country')
            
        def OpenFile(self):
            file = askopenfile(mode ='r', filetypes =[('all type',"*.*")]) 
#             if file is not None: 
#                 content = file.read() 
#                 print(content)

        
        
        btnSubmit=Button(self,text="Submit",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:create(self))
        btnSubmit.place(relx=0.2,rely=0.8,relwidth=0.3)
        btnStartPage=Button(self,text="Go to start page ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda: master.switch_frame(StartPage) )
        btnStartPage.place(relx=0.5,rely=0.8,relwidth=0.3)
        btnclearData=Button(self,text="Clear Data ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:clearData(self) )
        btnclearData.place(relx=0.2,rely=0.9,relwidth=0.3)
        btnquit=Button(self,text="Quit ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=master.destroy )
        btnquit.place(relx=0.5,rely=0.9,relwidth=0.3)
        btnSubmit.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnStartPage.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnclearData.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnquit.config(cursor='mouse',bg='navy', fg='white', bd=5)
        con = sq.connect('studb.db')
        c = con.cursor()

class PageTwo(tk.Frame):
    def __init__ (self,master):
        tk.Frame.__init__(self,master)
        tk.Frame.configure(self,bg='lawngreen')
        #tk.Frame.configure(master,bg='yellow')
        label=tk.Label(self,text=" ",bd=12,width=110,height=30,bg="lawngreen",fg="blue",font=("times",12,"bold","italic")).pack()
        label0=tk.Label(self,text="Student Records View Point",fg='#05386B',bg="lawngreen",pady=4,width=50,)
        label0.place(relx=0.17,rely=0.0)
        label0.config(font=("Vineta BT",10,"bold","italic"))
        
        def treeview1(self):
            
            con = sq.connect('studb.db')
            c = con.cursor()
            c.execute("SELECT * FROM stud ORDER BY roll DESC")
            
            self.tree=ttk.Treeview(self)
            self.tree["columns"]=("e1","e2","e3","e4","r1","d","de1")
            self.tree.column("#0", width=50, stretch=tk.NO)
            self.tree.column("e1", width=120, stretch=tk.NO)
            self.tree.column("e2", width=120,stretch=tk.NO)
            self.tree.column("e3", width=60, stretch=tk.NO)
            self.tree.column("e4", width=60, stretch=tk.NO)
            self.tree.column("r1", width=90, stretch=tk.NO)
            self.tree.column("d", width=95, stretch=tk.NO)
            self.tree.column("de1", width=95, stretch=tk.NO)
            self.tree.heading("#0",text="id",anchor=tk.W)
            self.tree.heading("e1", text="name",anchor=tk.W)
            self.tree.heading("e2", text="father name",anchor=tk.W)
            self.tree.heading("e3", text="age",anchor=tk.W)
            self.tree.heading("e4", text="roll num",anchor=tk.W)
            self.tree.heading("r1", text="gender",anchor=tk.W)
            self.tree.heading("d", text="country",anchor=tk.W)
            self.tree.heading("de1", text="DOB",anchor=tk.W)
            style = ttk.Style(self)
            style.theme_use("clam")
            style.configure("Treeview", fieldbackground="gray")

            tree = ttk.Treeview(self)
            self.tree.place(relx=0.2,rely=0.1,width=695,height=300)
           
             #self.tree.tag_configure("evenrow",background='white',foreground='black')
             #self.tree.tag_configure("oddrow",background='black',foreground='white')


            

            id=1
            for row in c:
                self.tree.insert("", 1, text=id, values=row)
                id=id+1
            con.commit()

        btnViewRec=tk.Button(self,text="View All Records",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:treeview1(self) )
        btnViewRec.place(relx=0.18,rely=0.8,relwidth=0.3)
        btnViewRec.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnStart=tk.Button(self,text="Go to start page ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda: master.switch_frame(StartPage) )
        btnStart.place(relx=0.5,rely=0.8,relwidth=0.3)
        btnStart.config(cursor='mouse',bg='navy', fg='white', bd=5)
#         def imgview(self):
#             self.img  = Image.open("web.gif")
#             self.img = self.img.resize((1500,500)) 
#             photo=ImageTk.PhotoImage(self.img)
#             self.lab=Label(self,image=photo)    
#             self.img.image=photo
#             self.lab.place(relx=0.0,rely=0.0)
#         return imgview(self)
class PageThree(tk.Frame):
    def __init__ (self,master):
        tk.Frame.__init__(self,master)
        tk.Frame.configure(self,bg='lawngreen')
        #tk.Frame.configure(master,bg='yellow')
        label=tk.Label(self,text=" ",bd=12,width=110,height=30,bg="lawngreen",fg="blue",font=("times",12,"bold","italic")).pack()
        label0=tk.Label(self,text="Student Records Delete Point",fg='#05386B',bg="lawngreen",pady=4,width=50,)
        label0.place(relx=0.17,rely=0.0)
        label0.config(font=("Vineta BT",10,"bold","italic"))
        
        
        labdelete1=Label(self,text='Give a Roll Num :',font=('none 13 bold'))
        labdelete1.place(relx=0.3,rely=0.5)
        self.rdelete=Entry(self,width=20,font=('none 13 bold'))
        self.rdelete.place(relx=0.3,rely=0.6)
        
        labdelete2=Label(self,text='Give a Name :',font=('none 13 bold'))
        labdelete2.place(relx=0.5,rely=0.5)
        self.ndelete=Entry(self,width=20,font=('none 13 bold'))
        self.ndelete.place(relx=0.5,rely=0.6)
        
        def delete1(self):    
            print("Record Deleted")
            con = sq.connect('studb.db')
            c = con.cursor()
            c.execute("DELETE FROM stud WHERE roll = " + self.rdelete.get())
            result1=tkinter.messagebox.askyesno("Delete","Do you want to delete this roll num ?")
            if result1==True:
                tkinter.messagebox.showinfo("Record Removed","Student record removed successfully")
            con.commit()
            
#         def delete2(self):    
#             print("Record Deleted")
#             con = sq.connect('studb.db')
#             c = con.cursor()
#             c.execute("DELETE FROM stud WHERE name = " + self.ndelete.get())
#             result1=tkinter.messagebox.askyesno("Delete","Do you want to delete this name ?")
#             if result1==True:
#                 tkinter.messagebox.showinfo("Record Removed","Student record removed successfully")
#             con.commit()
        
#         def deleteall(self):
#             print("All record deleted successfully")
#             con = sq.connect('studb.db')
#             c = con.cursor()
#             c.execute("DELETE FROM SQLITE_SEQUENCE WHERE name='stud'")
#             result1=tkinter.messagebox.askyesno("Delete","Do you want to reove all the records!!!")
#             if result1==True:
#                 tkinter.messagebox.showinfo("All Records Removed","Student record removed successfully")
#             con.commit()
        
        
        
        btndel1=tk.Button(self,text="Dlete Record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:delete1(self) )
        btndel1.place(relx=0.3,rely=0.7,relwidth=0.1)
        btndel1.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btndel2=tk.Button(self,text="Dlete Record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:delete2(self) )
        btndel2.place(relx=0.5,rely=0.7,relwidth=0.1)
        btndel2.config(cursor='mouse',bg='navy', fg='white', bd=5)
#         btndel3=tk.Button(self,text="Dlete all Records",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:deleteall(self) )
#         btndel3.place(relx=0.7,rely=0.7,relwidth=0.1)
#         btndel3.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnStart=tk.Button(self,text="Go to start page ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda: master.switch_frame(StartPage) )
        btnStart.place(relx=0.3,rely=0.8,relwidth=0.2)
        btnStart.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnView=tk.Button(self,text="View Records ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda: master.switch_frame(PageTwo) )
        btnView.place(relx=0.5,rely=0.8,relwidth=0.2)
        btnView.config(cursor='mouse',bg='navy', fg='white', bd=5)

class PageFour(tk.Frame):
     def __init__ (self,master):
        tk.Frame.__init__(self,master)
        tk.Frame.configure(self,bg='PeachPuff')
        #self.title("Entry Form")
        label=tk.Label(self,text=" ",bd=12,width=70,height=35,bg="lawngreen",fg="blue",font=("times",12,"bold","italic")).pack()
        
        label0=tk.Label(self,text="Update Student Records Here",fg='#05386B',bg="lawngreen",pady=4,width=50,)
        label0.place(relx=0.0,rely=0.0)
        label0.config(font=("Vineta BT",10,"bold","italic"))
        self.label1=tk.Label(self,text="Enter Roll Num ",width=20)
        self.label1.place(relx=0.1,rely=0.5)
        self.rsentry=tk.Entry(self)
        self.rsentry.place(relx=0.5,rely=0.5,relwidth=0.3)
        btnupdate=Button(self,text="Show record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:SelectRoll(self))
        btnupdate.place(relx=0.2,rely=0.6,relwidth=0.3)
        btnupdate.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnupdate=Button(self,text="Update Record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:RecUpdate(self))
        btnupdate.place(relx=0.5,rely=0.6,relwidth=0.3)
        btnupdate.config(cursor='mouse',bg='navy', fg='white', bd=5)
        record_rol=self.rsentry.get()
        labelinfo=tk.Label(self,text="NOTE:Gender,Country,DOB can't be Updated*",fg='red',bg="lawngreen",pady=4,width=50,)
        labelinfo.place(relx=0.2,rely=0.7)
        labelinfo.config(font=("Times New Roman",12,"bold","italic"))
        def RecUpdate(self):
            
            con = sq.connect('studb.db')
            c = con.cursor()
            record_rol=self.rsentry.get()
            c.execute("""UPDATE stud SET
                     name=:nm,
                     fname=:fnm,
                     age=:ag
                     WHERE roll=:roll""",
                     {'nm':self.nentry.get(),
                      'fnm':self.fentry.get(),
                      'ag':self.aentry.get(),
                      'roll':record_rol
                     })
            result1=tkinter.messagebox.askyesno("Update","Do you want to update this roll num ?")
            if result1==True:
                tkinter.messagebox.showinfo("Record Updated","Student record update successfully")
            con.commit()
            con.close()
            print("Record updated")
        def SelectRoll(self):
            print("Record selected")
            con = sq.connect('studb.db')
            c = con.cursor()
            record_id= self.rsentry.get()
            c.execute("SELECT * FROM stud WHERE roll = " + record_id )
            records=c.fetchall()

            global nentry
            global fentry
            global aentry
            global identry
            
            self.label1=tk.Label(self,text="Student Name*",width=20)
            self.label1.place(relx=0.1,rely=0.1)
            self.nentry=tk.Entry(self)
            self.nentry.place(relx=0.5,rely=0.1,relwidth=0.3)

           

            self.label2=tk.Label(self,text="Father's Name*",width=20)
            self.label2.place(relx=0.1,rely=0.2)
            self.fentry=tk.Entry(self)
            self.fentry.place(relx=0.5,rely=0.2,relwidth=0.3)

            self.label3=tk.Label(self,text="Age*",width=20)
            self.label3.place(relx=0.1,rely=0.3)
            self.aentry=tk.Entry(self)
            self.aentry.place(relx=0.5,rely=0.3,relwidth=0.3)

            self.label4=tk.Label(self,text="Student ID*",width=20)
            self.label4.place(relx=0.1,rely=0.4)
            self.identry=tk.Entry(self)
            self.identry.place(relx=0.5,rely=0.4,relwidth=0.3)

       
            for record in records:
                self.nentry.insert(0,record[0])
                self.fentry.insert(0,record[1])
                self.aentry.insert(0,record[2])
                self.identry.insert(0,record[3])
        def clearData(self):
            self.nentry.delete(0,END)
            self.fentry.delete(0,END)
            self.aentry.delete(0,END)
            self.identry.delete(0,END)
            self.rsentry.delete(0,END)
                
        btnSubmit=Button(self,text="view all record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:master.switch_frame(PageTwo))
        btnSubmit.place(relx=0.2,rely=0.8,relwidth=0.3)
        btnStartPage=Button(self,text="Go to start page ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda: master.switch_frame(StartPage) )
        btnStartPage.place(relx=0.5,rely=0.8,relwidth=0.3)
        btnclearData=Button(self,text="Clear Data ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:clearData(self) )
        btnclearData.place(relx=0.2,rely=0.9,relwidth=0.3)
        btnquit=Button(self,text="Quit ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=master.destroy )
        btnquit.place(relx=0.5,rely=0.9,relwidth=0.3)
        btnSubmit.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnStartPage.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnclearData.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnquit.config(cursor='mouse',bg='navy', fg='white', bd=5)
        con = sq.connect('studb.db')
        c = con.cursor()
class PageFive(tk.Frame):
     def __init__ (self,master):
        tk.Frame.__init__(self,master)
        tk.Frame.configure(self,bg='PeachPuff')
        #self.title("Entry Form")
        label=tk.Label(self,text=" ",bd=12,width=70,height=35,bg="lawngreen",fg="blue",font=("times",12,"bold","italic")).pack()
        
        label0=tk.Label(self,text="search Student Records Here",fg='#05386B',bg="lawngreen",pady=4,width=50,)
        label0.place(relx=0.0,rely=0.0)
        label0.config(font=("Vineta BT",10,"bold","italic"))
        self.label1=tk.Label(self,text="Enter Roll Num ",width=20)
        self.label1.place(relx=0.1,rely=0.5)
        self.rsentry=tk.Entry(self)
        self.rsentry.place(relx=0.5,rely=0.5,relwidth=0.3)
        btnupdate=Button(self,text="Show record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:SelectRoll(self))
        btnupdate.place(relx=0.2,rely=0.6,relwidth=0.3)
        btnupdate.config(cursor='mouse',bg='navy', fg='white', bd=5)
        
        
        labelinfo=tk.Label(self,text="NOTE:Gender,Country,DOB can't be viewd*",fg='red',bg="lawngreen",pady=4,width=50,)
        labelinfo.place(relx=0.2,rely=0.7)
        labelinfo.config(font=("Times New Roman",12,"bold","italic"))
        
        def SelectRoll(self):
            print("Record selected")
            con = sq.connect('studb.db')
            c = con.cursor()
            record_rol=self.rsentry.get()
            record_id= self.rsentry.get()
            
            c.execute("SELECT * FROM stud WHERE roll = " + record_rol )
            records=c.fetchall()
            
            
            self.label1=tk.Label(self,text="Student Name*",width=20)
            self.label1.place(relx=0.1,rely=0.1)
            self.nentry=tk.Entry(self)
            self.nentry.place(relx=0.5,rely=0.1,relwidth=0.3)

           

            self.label2=tk.Label(self,text="Father's Name*",width=20)
            self.label2.place(relx=0.1,rely=0.2)
            self.fentry=tk.Entry(self)
            self.fentry.place(relx=0.5,rely=0.2,relwidth=0.3)

            self.label3=tk.Label(self,text="Age*",width=20)
            self.label3.place(relx=0.1,rely=0.3)
            self.aentry=tk.Entry(self)
            self.aentry.place(relx=0.5,rely=0.3,relwidth=0.3)

            self.label4=tk.Label(self,text="Student ID*",width=20)
            self.label4.place(relx=0.1,rely=0.4)
            self.identry=tk.Entry(self)
            self.identry.place(relx=0.5,rely=0.4,relwidth=0.3)

       
            for record in records:
                self.nentry.insert(0,record[0])
                self.fentry.insert(0,record[1])
                self.aentry.insert(0,record[2])
                self.identry.insert(0,record[3])
        def clearData(self):
            self.nentry.delete(0,END)
            self.fentry.delete(0,END)
            self.aentry.delete(0,END)
            self.identry.delete(0,END)
            self.rsentry.delete(0,END)
                
        btnSubmit=Button(self,text="view all record",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:master.switch_frame(PageTwo))
        btnSubmit.place(relx=0.2,rely=0.8,relwidth=0.3)
        btnStartPage=Button(self,text="Go to start page ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda: master.switch_frame(StartPage) )
        btnStartPage.place(relx=0.5,rely=0.8,relwidth=0.3)
        btnclearData=Button(self,text="Clear Data ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=lambda:clearData(self) )
        btnclearData.place(relx=0.2,rely=0.9,relwidth=0.3)
        btnquit=Button(self,text="Quit ",bg="ghost white",font=("Helvetica",9,"bold","italic"),command=master.destroy )
        btnquit.place(relx=0.5,rely=0.9,relwidth=0.3)
        btnSubmit.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnStartPage.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnclearData.config(cursor='mouse',bg='navy', fg='white', bd=5)
        btnquit.config(cursor='mouse',bg='navy', fg='white', bd=5)
        con = sq.connect('studb.db')
        c = con.cursor()


app = SampleApp()
app.mainloop()


#===========Questions==============
#treeview order
#cant change title of the page
#roll num wise deleting but name wise not working
#if record not found show message
#validation in entries
#file  insertion into db
#select -- where clause operations
Record selected
In [80]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [9]:
from tkinter import *
from tkcalendar import *
from tkinter import messagebox
root=Tk()
def cal_func():
    def calval():
         messagebox.showinfo("your date is",cal.get_date())
    top=Toplevel(root)
    cal=Calendar(top,font="Arial 14",selectmode="none",year=2019,month=10,day=4)
    cal.pack(fill="both",expand=True)
    btn3=Button(top,text='click me',command=calval)
    btn3.pack()
def date_func():
    top=Toplevel(root)
    Label(top,text= "select date").pack(padx=10,pady=10)
    ent=DateEntry(top,backgroundcolor="yellow",foreground="red",borderwidth=3)
    ent.pack(padx=10,pady=10)
btn1=Button(root,text="calander",command=cal_func)
btn2=Button(root,text="DataEntry",command=date_func)
btn1.pack()
btn2.pack()
mainloop()
In [10]:
pip install tkcalendar
Requirement already satisfied: tkcalendar in c:\users\shakt\anaconda3\lib\site-packages (1.5.1) Requirement already satisfied: babel in c:\users\shakt\anaconda3\lib\site-packages (from tkcalendar) (2.7.0) Requirement already satisfied: pytz>=2015.7 in c:\users\shakt\anaconda3\lib\site-packages (from babel->tkcalendar) (2019.1) Note: you may need to restart the kernel to use updated packages.
In [90]:
import datetime
Year = int(input(" Please enter the year you were born "))
Month = int(input(" Please enter the number of the month you were born.  For example 3 = March "))
Day = int(input(" Please enter the day you were born "))
DOB = datetime.datetime(Year,Month,Day)
Age = (datetime.datetime.now() - DOB)
convertdays = int(Age.days)
AgeYears = int(convertdays/365)
print("Or " + str(AgeYears) + " years old ")
Please enter the year you were born 1997 Please enter the number of the month you were born. For example 3 = March 6 Please enter the day you were born 4 Or 22 years old
In [35]:
pip install tkintertable
Collecting tkintertable Downloading https://files.pythonhosted.org/packages/ce/37/18c3a3e3239a443e2427183f3148051ef7400dd163e75b54375bf73fb83c/tkintertable-1.3.2.tar.gz (56kB) Requirement already satisfied: future in c:\users\shakt\anaconda3\lib\site-packages (from tkintertable) (0.17.1) Building wheels for collected packages: tkintertable Building wheel for tkintertable (setup.py): started Building wheel for tkintertable (setup.py): finished with status 'done' Stored in directory: C:\Users\shakt\AppData\Local\pip\Cache\wheels\ca\0f\b7\dadb02c47e9702cb6ac05fe92c1cb39a52cdccfaab166502b1 Successfully built tkintertable Installing collected packages: tkintertable Successfully installed tkintertable-1.3.2 Note: you may need to restart the kernel to use updated packages.
In [50]:
import tkinter
from ScrolledText import *

root = tkinter.Tk(className=" Another way to create a Scrollable text area")
textPad = ScrolledText(root, width=50, height=40)
textPad.pack()
root.mainloop()
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-50-3e603c44103c> in <module> 1 import tkinter ----> 2 from ScrolledText import * 3 4 root = tkinter.Tk(className=" Another way to create a Scrollable text area") 5 textPad = ScrolledText(root, width=50, height=40) ModuleNotFoundError: No module named 'ScrolledText'