![]() # Refresh the data in the table and reset the input fields # Show a success message and close the database connection # Update the contact in the database using the current values of the input fieldsĬur.execute("update contact set firstname = ?, lastname = ?, mobile = ?, addr = ?, pin = ? where mobile = ?", ( ![]() Messagebox.showerror('Error', 'Select a record to update !') # Check if a record has been selected to update "select firstname, lastname, mobile, addr, pin from contact") Messagebox.showerror('Error', 'Please enter details ?')Ĭur.execute("insert into contact values(?,?,?,?,?)", ( # Create a button to calculate the Detailsītn1 = Button(btnFrame, text='Add record', font='arial 12 bold',īg='black', fg='white', width=9, command=self.addrecord)ītn1.grid(row=0, column=0, padx=10, pady=10)ītn2 = Button(btnFrame, text='Update', font='arial 12 bold',īg='black', fg='white', width=9, command=self.update)ītn2.grid(row=0, column=1, padx=8, pady=10)ītn3 = Button(btnFrame, text='Delete', font='arial 12 bold',īg='black', fg='white', width=9, command=lete)ītn3.grid(row=0, column=2, padx=8, pady=10)ītn4 = Button(btnFrame, text='Reset', font='arial 12 bold',īg='black', fg='white', width=9, command=self.reset)ītn4.grid(row=0, column=3, padx=8, pady=10) ntact_table.heading("pin", text="PinCode") ntact_table.heading("address", text="Address") ntact_table.heading("mobile", text="Mobile No.") ntact_table.heading("lastname", text="Last Name") ![]() ntact_table.heading("firstname", text="First Name") "firstname", "lastname", "mobile", "address", "pin"), yscrollcommand=t) ntact_table = ttk.Treeview(recordFrame, columns=( # Create a treeview to display the records Yscroll = Scrollbar(recordFrame, orient=VERTICAL) RecordFrame = Frame(self.root, bd=5, relief=RIDGE) Txt_pin = Entry(Detail_F, font=("Comic Sans MS", 10, ), Lbl_pin = Label(Detail_F, text="PinCode", font=("Comic Sans MS", 12, )) ![]() # Create a label and entry field for the pincode Txt_add = Entry(Detail_F, font=("Comic Sans MS", 10, ), Lbl_add = Label(Detail_F, text="Address", font=("Comic Sans MS", 12, )) # Create a label and entry field for the address Txt_aa = Entry(Detail_F, font=("Comic Sans MS", 10, ), Lbl_aa = Label(Detail_F, text="Mobile No.", # Create a label and entry field for the Mobile number Txt_mob = Entry(Detail_F, font=("Comic Sans MS", 10, ), Lbl_mob = Label(Detail_F, text="Last Name", # Create a label and entry field for the lastname Txt_name = Entry(Detail_F, font=("Comic Sans MS", 10, ), Lbl_name = Label(Detail_F, text="First Name", # Create a label and entry field for the firstname # Create a frame to hold the Contact detailsĭetail_F = Frame(self.root, bd=4, relief=RIDGE, bg='white')ĭetail_F.place(x=10, y=120, width=350, height=260) # Create StringVar variables to store the contact details Title = Label(self.root, text="ContactBook Management", font=( # Create a label with the title text and style it # Set the title and size of the root window # Initialize the class with the root window passed as an argument The default username and password are “root” and “root”, you can always change that later in the code. We will just need a single main.py file and the code for the same is written down here, the code is well commented so as to assist you with better learning. Persisting the contacts with the sqllite3 databaseĬomplete code for Contact Book project in Python.This is a simple app that can be used to handle contacts related to addresses or phones. Project overview: Contact Book project in Python Project Name: It can be used by individuals to manage and store contact details on their PC. A contact book is software that helps anyone to efficiently manage and track contacts. Today, we will develop a Contact Book project in Python.
0 Comments
Leave a Reply. |