Use python to realize business card management system

Python realizes business card management system (interface + database)

To develop a simple information management system (similar to the previous business card management system), it requires:

  1. Use structured or object-oriented development methods to develop systems
  2. Has a graphical user interface
  3. Store data in a database
  4. Implement the system with python language

Some functions are shown in the figure below

Interface when entering

Interface after displaying all business cards

New business card function

Created successfully

Find the business card contains (modify business card and delete business card)

The specific code is as follows

import sys
from tkinter import*from tkinter.messagebox import*from tkinter import ttk
import sqlite3
con = sqlite3.connect(r"D:\Python exercises\operation\December 6 python\card.db")
# con.execute("create table card(name primary key ,phone,QQ,email)")
# Add business card
def add():
add =Tk()
add.geometry('260x140+350+200')
add.minsize(260,140)
add.maxsize(260,140)
add.title("New business card")
lf =LabelFrame(add,text="please enter:",labelanchor=N)
lf.pack()Label(lf, text="Name:").grid(row=0,column=0)Label(lf, text="phone:").grid(row=1,column=0)Label(lf, text="Q Q:").grid(row=2, column=0)Label(lf, text="Email:").grid(row=3, column=0)
name =Entry(lf)
name.grid(row=0,column=1,columnspan=2)
phone =Entry(lf)
phone.grid(row=1,column=1,columnspan=2)
qq =Entry(lf)
qq.grid(row=2,column=1,columnspan=2)
email =Entry(lf)
email.grid(row=3,column=1,columnspan=2)
# OK button to add data
def qd_event():try:if name.get()=="":showinfo(title="prompt", message="The name cannot be empty!")
add.destroy()else:
con = sqlite3.connect(r"D:\Python exercises\operation\December 6 python\card.db")
cardList =(name.get(),phone.get(),qq.get(),email.get())
con.execute("insert into card(name,phone,QQ,email) values (?,?,?,?)",cardList)
# card ={"Name":name.get(),"phone":phone.get(),"QQ":qq.get(),"Email":email.get()}
# card_list.append(card)
con.commit()
con.close()
add.destroy()show_all()
# save_data()showinfo(title="prompt", message="Successfully created a new business card!")
except:print("error occur")showinfo(title="caveat", message="The name cannot be repeated!")
# Cancel button
def qx_event():
add.destroy()Button(lf,text="determine",command=qd_event).grid(row=4,column=2,sticky=W)Button(lf,text="cancel",command=qx_event).grid(row=4,column=1,sticky=E)
# Show all
def show_all():
x=dataTreeview.get_children()for item in x:
dataTreeview.delete(item)
con = sqlite3.connect(r"D:\Python exercises\operation\December 6 python\card.db")
cur = con.execute("select * from card")for i in cur:print(i)
n=0
# dataTreeview.insert('',1, values=("1","2","3","4"))
dataTreeview.insert('',n, values=i)
n+=1 
# Clear data
def del_all():
x=dataTreeview.get_children()for item in x:
dataTreeview.delete(item)
# Query business cards
def search_card():
search =Tk()
search.geometry('240x50+450+300')
search.minsize(240,80)
search.maxsize(400,170)
search.title("Find a business card")
lf =LabelFrame(search, text="please enter:", labelanchor=N)
lf.pack()Label(lf, text="Name:").grid(row=0, column=0)
name =Entry(lf)
name.grid(row=0, column=1, columnspan=2)
# print(name.get())
def sure():
con = sqlite3.connect(r"D:\Python exercises\operation\December 6 python\card.db")
cur = con.execute("select * from card")for i in cur:
# print(i)
# print(name.get())
# print(name.get()==i[0])if name.get()== i[0]:print("Find successful")
# print(i[0])update(i[0])
search.destroy()breakelse:showinfo(title="prompt",message="could not find it!")Button(lf, text="Find", command=sure).grid(row=1, column=1, sticky=N)
# Modify business card
def update(n):
update =Tk()
update.geometry('400x170+350+200')
update.minsize(400,170)
update.maxsize(400,170)
update.title("Find a business card")
lf1 =LabelFrame(update, text="Business card information",labelanchor=N)
lf1.pack()Label(lf1, text="Name:").grid(row=0, column=0)Label(lf1, text="phone:").grid(row=1, column=0)Label(lf1, text="Q Q:").grid(row=2, column=0)Label(lf1, text="Email:").grid(row=3, column=0)
con = sqlite3.connect(r"D:\Python exercises\operation\December 6 python\card.db")print(n+"So pretty")
cur = con.execute("select * from card where name =="+"'"+n+"'")print("'"+n+"'")for i in cur:print(i[0]+i[1]+i[2]+i[3])Label(lf1, text=i[0], width=20, anchor=W).grid(row=0, column=1, columnspan=2)Label(lf1, text=i[1], width=20, anchor=W).grid(row=1, column=1, columnspan=2)Label(lf1, text=i[2], width=20, anchor=W).grid(row=2, column=1, columnspan=2)Label(lf1, text=i[3], width=20, anchor=W).grid(row=3, column=1, columnspan=2)
name =Entry(lf1)
name.grid(row=0, column=3, columnspan=2)
phone =Entry(lf1)
phone.grid(row=1, column=3, columnspan=2)
qq =Entry(lf1)
qq.grid(row=2, column=3, columnspan=2)
email =Entry(lf1)
email.grid(row=3, column=3, columnspan=2)Label(lf1,text="prompt! Modify the business card and enter the blank space to confirm the modification",anchor=E).grid(row=4, column=0, columnspan=3)
def xg_event(n):print(n)print(name.get()) 
con = sqlite3.connect(r"D:\Python exercises\operation\December 6 python\card.db")
con.execute("update card set name=?,phone=?,qq=?,email=? where name ="+"'"+n+"'",(name.get(),phone.get(),qq.get(),email.get()))
con.commit()
con.close()
update.destroy()show_all()
# Delete business card
def delete(n):
con = sqlite3.connect(r"D:\Python exercises\operation\December 6 python\card.db")
con.execute("delete from card where name ="+"'"+n+"'")
con.commit()
con.close()show_all()showinfo(title="prompt", message="deleted!")
update.destroy()Button(lf1, text="modify", command=lambda:xg_event(n)).grid(row=5, column=2, sticky=E)Button(lf1, text="delete", command=lambda:delete(n)).grid(row=5, column=1, sticky=E)
# Exit system
def quit():
root.destroy()
def about():showinfo(title="about us",message="Card Management System\n version number: V4.0 \n Author: PERFECTION new\nCompletion date: December 18, 2019")
# Create a Tk root window component root
root=Tk()
root.title("Business Card Management System")
root["width"]=800
root["height"]=500
# System management menu bar
mubar=Menu(root)
muLogin=Menu(mubar,tearoff=0)
mubar.add_cascade(label="System Management",menu=muLogin)
muLogin.add_command(label="Download Data",command=show_all)
muLogin.add_command(label="Clear data",command=del_all)
tc=muLogin.add_command(label="drop out",command=quit)
# Business card management menu bar
muCard=Menu(mubar,tearoff=0)
mubar.add_cascade(label="Business card management",menu=muCard)
muCard.add_command(label="Show all",command=show_all)
root.bind("<Button-1 ,")
muCard.add_command(label="New",command=add)
muCard.add_command(label="Find",command=search_card)
muCard.add_command(label="save")
# Help menu bar
muHelp=Menu(mubar,tearoff=0)
mubar.add_cascade(label="help",menu=muHelp)
muHelp.add_command(label="on",command=about)
t=Text(root,width=100,height=30)
t.pack()
dataTreeview = ttk.Treeview(root, height=19,show='headings', column=('name','phone','QQ','email'))
dataTreeview.column('name', width=80, anchor="center")
dataTreeview.column('phone', width=80, anchor="center")
dataTreeview.column('QQ', width=80, anchor="center")
dataTreeview.column('email', width=80, anchor="center")
dataTreeview.heading('name', text='Name')
dataTreeview.heading('phone', text='phone')
dataTreeview.heading('QQ', text='QQ')
dataTreeview.heading('email', text='mailbox')
dataTreeview.place(rely=0, relwidth=1)Label(root, text='Business Card Management System V4.0', bg='white', fg='blue', font=('Song Ti',15)).pack(side=BOTTOM, fill='x')
root["menu"]=mubar
root.mainloop()

For more learning materials, please pay attention to the topic "Management System Development".

The above is the whole content of this article, I hope it will be helpful to everyone's study.

Recommended Posts

Use python to realize business card management system
Python realizes business card management system
Python3 realizes business card management system
Python implements a simple business card management system
Implementation of business card management system with python
Implementation of business card management system based on python
Use python to realize the aircraft war game
Python implements parking management system
Python implements car management system
How to use python tuples
How to use python thread pool
Use python to query Oracle database
Implementing student management system with python
Use C++ to write Python3 extensions
Implementation of python student management system
How to use SQLite in Python
How to use and and or in Python
Use Python to make airplane war games
How to use PYTHON to crawl news articles
Python | So collections are so easy to use! !
Use Python to generate Douyin character videos!
Use Python to quickly cut out images
Use python3 to install third on ubuntu
How to use the round function in python
Dry goods | Use Python to operate mysql database
How to use the zip function in Python
Python realizes the development of student management system
How to use dpkg command in Ubuntu system
How to use the format function in python
How to use code running assistant in python
[Practice] How to install python3.6 on Ubuntu system
01. Introduction to Python
centos system management
Python crawler-beautifulsoup use
Introduction to Python
Python simulation to realize the distribution of playing cards