Atul Soni Python Project Final Report
Atul Soni Python Project Final Report
Ashish Kumar
Reg. no. - 12115448
Section - K21QT
Roll no. - A33
Subject - Python(project)
Teacher - Er. Navpreet Rupal
Topic - Courier Management System
College - Lovely Professional University
About Courier Management
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 inbuilt module of Python which
is used to generate random numbers
Creating the database and table for the courier
management system
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()
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.
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
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()
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
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:
self.logf.configure(background='skyblue')
self.logf.pack()
R2 = Radiobutton(self.crf, text="Female",
variable=var, value=2,bg='lightgreen').grid(row=5,
column=2)
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
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.
import sqlite3
import random
# Database
c = db.cursor()
try:
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):
c = db.cursor()
c.execute(find_user, [(self.username.get()),
(self.password.get())])
result = c.fetchall()
if result:
self.track()
else:
def new_user(self):
c = db.cursor()
c.execute(find_user, [(self.n_username.get())])
if c.fetchall():
ms.showerror('Error!', 'Username is already taken.')
else:
c.execute(insert, [(self.n_username.get()),
(self.n_password.get()), (self.n_mobile.get())])
db.commit()
self.log()
else:
def consignment(self):
try:
c = db.cursor()
result = c.fetchall()
if result:
self.track()
self.crff.pack_forget()
self.consi.pack()
else:
except:
def track1(self):
self.consi.pack_forget()
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.crf.pack()
def track(self):
self.logf.pack_forget()
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.configure(background='skyblue')
command=self.login).grid(row=8, column=0)
command=self.create).grid(row=8, column=1)
self.logf.pack()
self.crf = Frame(self.master, padx=60,
pady=60,bg='lightgreen')
var = IntVar()
command=self.new_user).grid(row=11, column=0)
command=self.log).grid(row=11, column=2)
command=self.consignment).grid(row=4,
column=0)
Label(self.consi, text=random.randint(500000,
99994216), font=('Calibri', 13),bg='lightgreen').grid(row=0,
column=1)
f = random.randint(0, 10)
Label(self.consi, text='Product is : ', font=('Calibri',
13),bg='lightgreen').grid(sticky=W)
command=self.track1).grid(row=6, column=0)
if __name__ == '__main__':
root = Tk()
root.geometry('800x450+0+0')
root.mainloop()
Summary