About Courier Management System Project in Python
In the Courier Management System project in Python, we are going to learn about how to create a management system to track packages or couriers that are delivered to a specific destination. How does the consignment is tracked and what is the current status of the package? All these things we are going to learn in our article i.e Courier Management System Project In Python with source code.
The Package delivery Management System Project In Python is developed using Python Programming, This Project along with source code is created using Graphical User Interface (GUI) Tkinter and connected to the database using SQLlite3. This project is good for beginners or students and also for final-year students who want to learn Python Programming Language.
Project Overview: Courier Management System Python Project
Project Name: | Courier Management System Project in Python |
Abstract: | A GUI-based program in python that basically includes the use of the Tkinter and Sqlite3 database for the execution. |
Language/Technologies Used: | Python, Tkinter |
IDE | Pycharm(Recommended) |
Database | SQLite3 |
Python version (Recommended): | 3.8 or 3.9 |
Type/Category: | Final Year Project using Python |
Features and benefits of Courier/Package Management System
The basic task to be performed on this Project are:
- Create an account if you are a new user and log in if you are already registered.
- Add all the details of the user who wants to track the courier or package delivered to the destination.
- Check the current status of the package.
Use of Pycharm IDE for Project
- First Install Pycharm Community Edition 2021.3.1 (community edition is to be installed)
- Create New Project by clicking on File and selecting New Project, writing the project name, and clicking on “Create”.
3. Right-click on the project name you have created and Create a New Python File as “couriermanage.py”.
4. Write the code in the file and execute the Python Program for the courier management system by Clicking the “Run” tab.
Note: You can install the modules by going to “File”->” Settings”-> ”Project: Courier Management”->” Python Interpreter”->click on the”+” sign and write the name of the module want to install and click on “Install package”.
Code flow: Courier Management System in python with source code
Importing the libraries
from tkinter import *
from tkinter import messagebox as ms
from tkinter import ttk
import sqlite3
import random
from tkinter import Button
Explanation:
The import function includes these modules in the project
These modules are used for the following purposes:
1. Tkinter – To create the GUI.
2. SQLite3 – To connect the program to the database and store information in it.
3. Tkinter.messagebox – To show a display box, displaying some information or an error or warning
4. Tkinter.ttk – To create the tree where all the information will be displayed.
5. random– It is an in-built module of Python which is used to generate random numbers.
Creating the database and table for the courier management system
with sqlite3.connect('record123.db') as db:
c = db.cursor()
try:
c.execute('CREATE TABLE IF NOT EXISTS user (username TEXT NOT NULL ,password TEX NOT NULL,mobile TEX NOT NULL);')
except:
pass
db.commit()
db.close()
Explanation:
Here we have created a database “record123” and performed the database connection with sqlite3. This is stored in a variable db. After that, the cursor object c is created for executing the queries. In the try block, we are using the execute method in which we are creating a table user if it doesn’t exist else it will do nothing i.e pass. The commit() is used to save the changes.
Declaring the variables required for the project
class main:
def __init__(self, master):
self.master = master
self.username = StringVar()
self.password = StringVar()
self.n_username = StringVar()
self.n_password = StringVar()
self.n_reg = StringVar()
self.n_mobile = StringVar()
self.mobile11 = StringVar()
self.widgets()
Explanation:
In this code block, we have declared the main class, where we have defined a init method in which the variables of string type have been declared. The self-parameter is a reference to the current instance of the class and is used to access variables that belong to the class.
Code for creating the Login function
def login(self):
with sqlite3.connect('record123.db') as db:
c = db.cursor()
# Find the correct user
find_user = ('SELECT * FROM user WHERE username = ? and password = ?')
c.execute(find_user, [(self.username.get()), (self.password.get())])
result = c.fetchall()
if result:
self.track()
else:
ms.showerror('Oops!', 'Check the username again.')
Explanation:
Here, in the function def login(self): We are working on our database created in sqlite3 i.e record123.db. The find_user is the variable that stored the value on the execution of the query. The query is used to check whether the user with the username and password we provide is already present in the database. If it is present it will fetch all the data with fetchall() method and store the output in the variable result. If the result is present then it will track else it will show an error msg “’Oops!’, ‘Username Not Found.”.
Output
Develop a code for creating a new user account
def new_user(self):
with sqlite3.connect('record123.db') as db:
c = db.cursor()
if self.n_username.get() != ' ' and self.n_password.get() != ' ' and self.n_mobile.get() != ' ':
find_user = ('SELECT * FROM user WHERE username = ?')
c.execute(find_user, [(self.n_username.get())])
if c.fetchall():
ms.showerror('Error!', 'Username is already taken.')
else:
insert = 'INSERT INTO user(username,password,mobile) VALUES(?,?,?)'
c.execute(insert, [(self.n_username.get()), (self.n_password.get()), (self.n_mobile.get())])
db.commit()
ms.showinfo('Congrats!', 'Account Created!')
self.log()
else:
ms.showerror('Error!', 'Please Enter the details.')
Explanation:
def new_user(self): In this code block, we are creating a new user if not created in our database record123.db. For that, we will create a new account that stores the information of the user such as name, password, registration number, gender, mobile no, and email where the name, password, and mobile number are used to track the package.
In the if the block it will check whether the user with the username is present it will be stored in the variable find_user. If the user is already present it will print the message ‘Error!’, ‘Username is already Taken.‘
Else create a new account by clicking on “New User”. Store the values. Once it’s done it will show a message” ‘Success!’, ‘Account Created!‘.else it will show a msg “Error!’, ‘Please Enter the details.’
Output:
Code to track the courier/package
def consignment(self):
try:
with sqlite3.connect('record123.db') as db:
c = db.cursor()
# Find user If there is any take proper action
find_user = ('SELECT * FROM user WHERE mobile= ?')
c.execute(find_user, [(self.mobile11.get())])
result = c.fetchall()
if result:
self.track()
self.crff.pack_forget()
self.head['text'] = self.username.get() + '\n Your Product Details'
self.consi.pack()
else:
ms.showerror('Oops!', 'Mobile Number Not Found.')
except:
ms.showerror('Oops!', 'Mobile Number Not Found.')
Explanation:
def consignment(self): In this code block, we are making use of the database record123.db.Here we will check for the mobile number and consignment number while tracking, if the mobile number is present in the database all the details related to the mobile number are fetched in the result. If the result is true it will show the product details else will show an error message as “’Oops!’, ‘Mobile Number Not Found.’
Output
Code to view the tracking information
def track1(self):
self.consi.pack_forget()
self.head['text'] = self.username.get() + '\n Product Tracking Information'
self.crff.pack()
def log(self):
self.username.set('')
self.password.set('')
self.crf.pack_forget()
self.head['text'] = 'Login'
self.logf.pack()
def create(self):
self.n_username.set('')
self.n_password.set('')
self.logf.pack_forget()
self.head['text'] = 'Open your Account'
self.crf.pack()
def track(self):
self.logf.pack_forget()
self.head['text'] = self.username.get() + '\n Tracking the Product'
self.crff.pack()
Explanation:
def track(self): It checks for the tracking of the package. The “text” variable takes the username and Tracks the product.
def log(self): The log function is used for the login page takes the username and password and the “text” variable takes the “Login” text for logging to the page.
def create(self): It is used for creating the account.
Module containing frames, text, labels, and buttons of the courier management system in python
def widgets(self):
self.head = Label(self.master, text='LOGIN THE PAGE', font=('Calibri', 18), pady=15)
self.head.pack()
self.logf = Frame(self.master, padx=50, pady=50)
self.logf.configure(background='skyblue')
Label(self.logf, text='Username: ', font=('', 12), pady=4, padx=4,bg='SkyBlue').grid(sticky=W)
Entry(self.logf, textvariable=self.username, bd=3, font=('', 15)).grid(row=0, column=1)
Label(self.logf, text='Password: ', font=('', 12), pady=4, padx=4,bg='SkyBlue').grid(sticky=W)
Entry(self.logf, textvariable=self.password, bd=3, font=('', 15), show='*').grid(row=1, column=1)
Button(self.logf, text=' Enter Login ', background='lightgrey', bd=4, font=('', 13), padx=5, pady=5,
command=self.login).grid(row=8, column=0)
Button(self.logf, text=' New Registration ', background='lightgrey', bd=4, font=('', 13), padx=6, pady=6,
command=self.create).grid(row=8, column=1)
self.logf.pack()
self.crf = Frame(self.master, padx=60, pady=60,bg='lightgreen')
Label(self.crf, text='Username: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W)
Entry(self.crf, textvariable=self.n_username, bd=3, font=('', 15)).grid(row=0, column=1)
Label(self.crf, text='Password: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W)
Entry(self.crf, textvariable=self.n_password, bd=3, font=('', 15), show='*').grid(row=1, column=1)
Label(self.crf, text='Mobile No.: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W)
Entry(self.crf, textvariable=self.n_mobile, bd=3, font=('', 15)).grid(row=2, column=1)
Label(self.crf, text='Registration No.: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W)
Entry(self.crf, textvariable=self.n_reg, bd=3, font=('', 15)).grid(row=3, column=1)
Label(self.crf, text='Email Id: ', font=('Calibri', 15), pady=5, padx=5, bg='lightgreen').grid(sticky=W)
Entry(self.crf, bd=3, font=('', 15)).grid(row=4, column=1)
Label(self.crf, text='Gender: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W)
var = IntVar()
R1 = Radiobutton(self.crf, text="Male", variable=var, value=1,bg='lightgreen').grid(row=5,column=1)
R2 = Radiobutton(self.crf, text="Female", variable=var, value=2,bg='lightgreen').grid(row=5, column=2)
Button(self.crf, text='Create My Account', background='lightgrey', bd=2, font=('Calibri', 13), padx=8, pady=8,
command=self.new_user).grid(row=11, column=0)
Button(self.crf, text='Back to Login', background='lightgrey', bd=2, font=('Calibri', 13), padx=8, pady=8,
command=self.log).grid(row=11, column=2)
self.crff = Frame(self.master, padx=80, pady=80,bg='lightgreen')
Label(self.crff, text='Reference No: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W)
Entry(self.crff, bd=3, font=('Calibri', 15)).grid(row=0, column=1)
Label(self.crff, text='Mobile no:', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W)
Entry(self.crff, bd=3, textvariable=self.mobile11, font=('Calibri', 15)).grid(row=1, column=1)
Button(self.crff, text='Track', background='steelBlue', bd=2, font=('Calibri', 13), padx=6, pady=6,
command=self.consignment).grid(row=4, column=0)
self.consi = Frame(self.master, padx=80, pady=80,bg='lightgreen')
Label(self.consi, text='Product ID:', font=('Calibri', 13),bg='lightgreen').grid(sticky=W)
Label(self.consi, text=random.randint(500000, 99994216), font=('Calibri', 13),bg='lightgreen').grid(row=0, column=1)
L = ['Shoes', 'Brushes', 'Purse', 'Vivo', 'Jeans', 'baby wash', 'Mac', 'Ipad', 'Saree', 'Book', 'shirt']
f = random.randint(0, 10)
Label(self.consi, text='Product is : ', font=('Calibri', 13),bg='lightgreen').grid(sticky=W)
Label(self.consi, text=L[f], font=('Calibri', 13),bg='lightgreen').grid(row=1, column=1)
Label(self.consi, text='Status: ', font=('Calibri', 13),bg='lightgreen').grid(sticky=W)
Label(self.consi, text='Pending,On the way', font=('Calibri', 13),bg='lightgreen').grid(row=2, column=1)
Label(self.consi, font=('Calibri', 13), text='Thank You',bg='lightgreen').grid(row=5, column=0)
Button(self.consi, text='Back', background='lightgrey', bd=2, font=('', 13),
command=self.track1).grid(row=6, column=0)
Explanation:
Here we have provided all the widgets that are required for the form creation of login, tracking, and delivery. We are using the randint function of the random module for randomly selecting the product numbers and we have defined the 10 products which the system selects randomly while executing the program.
Output
Creating a display window
if __name__ == '__main__': root = Tk() root.title('Tracking the Product') root.geometry('800x450+0+0') main(root)
Explanation:
Here we have defined the main function, where The root window is created. The root window is the main application window in our programs. We have defined the title of the window as “Track consignment”. The window size is defined using the geometry function. The root.mainloop() is simply a method in the main window that executes what we wish to execute in an application.
Complete source code for courier management system using Tkinter in python
#Import the modules from tkinter import * from tkinter import messagebox as ms from tkinter import ttk import sqlite3 import random from tkinter import Button # Database with sqlite3.connect('record123.db') as db: c = db.cursor() try: c.execute('CREATE TABLE IF NOT EXISTS user (username TEXT NOT NULL ,password TEX NOT NULL,mobile TEX NOT NULL);') except: pass db.commit() db.close() class main: def __init__(self, master): self.master = master self.username = StringVar() self.password = StringVar() self.n_username = StringVar() self.n_password = StringVar() self.n_reg = StringVar() self.n_mobile = StringVar() self.mobile11 = StringVar() self.widgets() def login(self): with sqlite3.connect('record123.db') as db: c = db.cursor() # Find the correct user find_user = ('SELECT * FROM user WHERE username = ? and password = ?') c.execute(find_user, [(self.username.get()), (self.password.get())]) result = c.fetchall() if result: self.track() else: ms.showerror('Oops!', 'Check the username again.') def new_user(self): with sqlite3.connect('record123.db') as db: c = db.cursor() if self.n_username.get() != ' ' and self.n_password.get() != ' ' and self.n_mobile.get() != ' ': find_user = ('SELECT * FROM user WHERE username = ?') c.execute(find_user, [(self.n_username.get())]) if c.fetchall(): ms.showerror('Error!', 'Username is already taken.') else: insert = 'INSERT INTO user(username,password,mobile) VALUES(?,?,?)' c.execute(insert, [(self.n_username.get()), (self.n_password.get()), (self.n_mobile.get())]) db.commit() ms.showinfo('Congrats!', 'Account Created!') self.log() else: ms.showerror('Error!', 'Please Enter the details.') def consignment(self): try: with sqlite3.connect('record123.db') as db: c = db.cursor() # Find user If there is any take proper action find_user = ('SELECT * FROM user WHERE mobile= ?') c.execute(find_user, [(self.mobile11.get())]) result = c.fetchall() if result: self.track() self.crff.pack_forget() self.head['text'] = self.username.get() + '\n Your Product Details' self.consi.pack() else: ms.showerror('Oops!', 'Mobile Number Not Found.') except: ms.showerror('Oops!', 'Mobile Number Not Found.') def track1(self): self.consi.pack_forget() self.head['text'] = self.username.get() + '\n Product Tracking Information' self.crff.pack() def log(self): self.username.set('') self.password.set('') self.crf.pack_forget() self.head['text'] = 'Login' self.logf.pack() def create(self): self.n_username.set('') self.n_password.set('') self.logf.pack_forget() self.head['text'] = 'Open your Account' self.crf.pack() def track(self): self.logf.pack_forget() self.head['text'] = self.username.get() + '\n Tracking the Product' self.crff.pack() def widgets(self): self.head = Label(self.master, text='LOGIN THE PAGE', font=('Calibri', 18), pady=15) self.head.pack() self.logf = Frame(self.master, padx=50, pady=50) self.logf.configure(background='skyblue') Label(self.logf, text='Username: ', font=('', 12), pady=4, padx=4,bg='SkyBlue').grid(sticky=W) Entry(self.logf, textvariable=self.username, bd=3, font=('', 15)).grid(row=0, column=1) Label(self.logf, text='Password: ', font=('', 12), pady=4, padx=4,bg='SkyBlue').grid(sticky=W) Entry(self.logf, textvariable=self.password, bd=3, font=('', 15), show='*').grid(row=1, column=1) Button(self.logf, text=' Enter Login ', background='lightgrey', bd=4, font=('', 13), padx=5, pady=5, command=self.login).grid(row=8, column=0) Button(self.logf, text=' New Registration ', background='lightgrey', bd=4, font=('', 13), padx=6, pady=6, command=self.create).grid(row=8, column=1) self.logf.pack() self.crf = Frame(self.master, padx=60, pady=60,bg='lightgreen') Label(self.crf, text='Username: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W) Entry(self.crf, textvariable=self.n_username, bd=3, font=('', 15)).grid(row=0, column=1) Label(self.crf, text='Password: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W) Entry(self.crf, textvariable=self.n_password, bd=3, font=('', 15), show='*').grid(row=1, column=1) Label(self.crf, text='Mobile No.: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W) Entry(self.crf, textvariable=self.n_mobile, bd=3, font=('', 15)).grid(row=2, column=1) Label(self.crf, text='Registration No.: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W) Entry(self.crf, textvariable=self.n_reg, bd=3, font=('', 15)).grid(row=3, column=1) Label(self.crf, text='Email Id: ', font=('Calibri', 15), pady=5, padx=5, bg='lightgreen').grid(sticky=W) Entry(self.crf, bd=3, font=('', 15)).grid(row=4, column=1) Label(self.crf, text='Gender: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W) var = IntVar() R1 = Radiobutton(self.crf, text="Male", variable=var, value=1,bg='lightgreen').grid(row=5,column=1) R2 = Radiobutton(self.crf, text="Female", variable=var, value=2,bg='lightgreen').grid(row=5, column=2) Button(self.crf, text='Create My Account', background='lightgrey', bd=2, font=('Calibri', 13), padx=8, pady=8, command=self.new_user).grid(row=11, column=0) Button(self.crf, text='Back to Login', background='lightgrey', bd=2, font=('Calibri', 13), padx=8, pady=8, command=self.log).grid(row=11, column=2) self.crff = Frame(self.master, padx=80, pady=80,bg='lightgreen') Label(self.crff, text='Reference No: ', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W) Entry(self.crff, bd=3, font=('Calibri', 15)).grid(row=0, column=1) Label(self.crff, text='Mobile no:', font=('Calibri', 15), pady=5, padx=5,bg='lightgreen').grid(sticky=W) Entry(self.crff, bd=3, textvariable=self.mobile11, font=('Calibri', 15)).grid(row=1, column=1) Button(self.crff, text='Track', background='steelBlue', bd=2, font=('Calibri', 13), padx=6, pady=6, command=self.consignment).grid(row=4, column=0) self.consi = Frame(self.master, padx=80, pady=80,bg='lightgreen') Label(self.consi, text='Product ID:', font=('Calibri', 13),bg='lightgreen').grid(sticky=W) Label(self.consi, text=random.randint(500000, 99994216), font=('Calibri', 13),bg='lightgreen').grid(row=0, column=1) L = ['Shoes', 'Brushes', 'Purse', 'Vivo', 'Jeans', 'baby wash', 'Mac', 'Ipad', 'Saree', 'Book', 'shirt'] f = random.randint(0, 10) Label(self.consi, text='Product is : ', font=('Calibri', 13),bg='lightgreen').grid(sticky=W) Label(self.consi, text=L[f], font=('Calibri', 13),bg='lightgreen').grid(row=1, column=1) Label(self.consi, text='Status: ', font=('Calibri', 13),bg='lightgreen').grid(sticky=W) Label(self.consi, text='Pending,On the way', font=('Calibri', 13),bg='lightgreen').grid(row=2, column=1) Label(self.consi, font=('Calibri', 13), text='Thank You',bg='lightgreen').grid(row=5, column=0) Button(self.consi, text='Back', background='lightgrey', bd=2, font=('', 13), command=self.track1).grid(row=6, column=0) if __name__ == '__main__': root = Tk() root.title('Tracking the Product') root.geometry('800x450+0+0') main(root) root.mainloop()
Output
Summary
In this article, we have learned to develop the package or courier management system using python programming language and using the GUI Tkinter module connecting to the SQLite3 database and performing the functions of product tracking.
We hope that this article is useful for you. For more articles on python programming keep visiting our website.
Thank you for visiting our website.
Also Read:
- Download 1000+ Projects, All B.Tech & Programming Notes, Job, Resume & Interview Guide, and More – Get Your Ultimate Programming Bundle!
- Music Recommendation System in Machine Learning
- Create your own ChatGPT with Python
- Bakery Management System in Python | Class 12 Project
- SQLite | CRUD Operations in Python
- Event Management System Project in Python
- Ticket Booking and Management in Python
- Hostel Management System Project in Python
- Sales Management System Project in Python
- Bank Management System Project in C++
- Python Download File from URL | 4 Methods
- Python Programming Examples | Fundamental Programs in Python
- Spell Checker in Python
- Portfolio Management System in Python
- Stickman Game in Python
- Contact Book project in Python
- Loan Management System Project in Python
- Cab Booking System in Python
- Brick Breaker Game in Python
- 100+ Java Projects for Beginners 2023
- Tank game in Python
- GUI Piano in Python
- Ludo Game in Python
- Rock Paper Scissors Game in Python
- Snake and Ladder Game in Python
- Puzzle Game in Python
- Medical Store Management System Project in Python
- Creating Dino Game in Python
- Tic Tac Toe Game in Python
- Courier Tracking System in HTML CSS and JS