Complaint Management System Project in Python Source Code

This is a simple system project, and you will learn how to create a simple Complaint Management System Project in Python with Source Code.

Complaint Management System in Python: Project Details and Technology

Project Name:Complaint Management System Python Project
AbstractA complaint Management System in Python is a way for customers to let the company know what they don’t like about it.
Language/s Used:Python Programming
Python version (Recommended):3.8 or 3.9
Database:SQLite3
Type:Python Tkinter Based Project
Developer:IT SOURCECODE
Updates:0
Complaint Management System in Python Project Information

A simple system includes a downloadable Complaint Management System using Python.

About Complaint Management System Python Project

The Complaint Management System is a simple desktop application and the database used in this system is Sqlite3. The complaint Management System is created using Python programming language.

The Complaint Management System project file contains python scripts(complain-system-main.py, configdb.py, complaintListing.py) and sqlite database. Complaint Management System is using a Tkinter graphical user interface(GUI).

To start creating a Complaint Management System in Python, make sure you have PyCharm IDE and SQLITE3 installed on your computer.

By the way, if you are new to Python programming and don’t know what Python IDE to use, I have here a list of the Best Python IDE for Windows, Linux, and Mac OS that will suit you.

I also have here How to Download and Install Latest Version of Python on Windows.

Steps on How To Create a Complaint Management System Project in Python.

Time needed: 5 minutes

Complaint Management System in Python with Source Code

  • Step 1: Create a Project Name.

    First step open the PyCharm IDE and click “File” and select “New Project” and then create a project name after that click the “create” button.Create project name in Complaint system in python

  • Step 2: Create a Python File.

    In the second step after creating a project name, “right” click the project name, and then click “New.” After that choose “Python File“.Create python name in Complaint system in python

  • Step 3: Name the Python File.

    The third step after choosing Python File name the file “Complaint System” and then click “Enter“.Naming python file name in Complaint system in python

  • Step 4: The actual code.

    Now you can start coding, you are free to copy the code that being provided below.

Code Explanations

1. Importing Tkinter Module

Tkinter is the standard GUI library for Python. Python when combined with Tkinter provides a fast and easy way to create GUI applications. 

from tkinter import *
from tkinter.ttk import *
from tkinter.messagebox import *

In the code above, which is for importing tkinter just write 3 lines of code.

2. Importing the Sqlite3 Module

SQLite is a C library that provides a lightweight disk-based database that doesn’t require a separate server process and allows accessing the database using a nonstandard variant of the SQL query language. 

import sqlite3

In the code above, which is for importing sqlite just write one line of code.

3. Create Database

This module is for Creating a Database.

def __init__(self):
self._db = sqlite3.connect('complaintDB.db')
self._db.row_factory = sqlite3.Row
self._db.execute('create table if not exists complainTable(ID integer primary key autoincrement, FirstName varchar(255), LastName varchar(255), Address Text, Gender varchar(255), Comment text)')
self._db.commit()

In the code above, which is for creating a database name “complaintDb.db” and for the table name “complainTable.”

4. Main Window

The Design and Style for the Main Window.

So first of all you have to design the main screen. This display screen has a label of first name, last name, gender, and comment, the radio buttons have only two male and female, and for the buttons, it is view complain and submit now.

So let’s see the way to put it into effect:

conn = ConnectionDatabase()
root = Tk()
root.geometry('550x350')
root.title('Complaint Management System')
root.configure(bg='blue')


labels = ['First Name:', 'Last Name:', 'Address:', 'Gender:', 'Comment:']
for i in range(4):
Label(root, text=labels[i]).grid(row=i, column=0, padx=10, pady=10)


ButtonList = Button(root, text='View Complain')
ButtonList.grid(row=5, column=1)

BuSubmit = Button(root, text='Submit Now')
BuSubmit.grid(row=5, column=2)

# Entries
firstname = Entry(root, width=40, font=('Arial', 14))
firstname.grid(row=0, column=1, columnspan=2)

lastname = Entry(root, width=40, font=('Arial', 14))
lastname.grid(row=1, column=1, columnspan=2)

address = Entry(root, width=40, font=('Arial', 14))
address.grid(row=2, column=1, columnspan=2)

GenderGroup = StringVar()
Radiobutton(root, text='Male', value='male', variable=GenderGroup).grid(row=3, column=1)
Radiobutton(root, text='Female', value='female', variable=GenderGroup).grid(row=3, column=2)

comment = Text(root, width=40, height=5, font=('Arial', 14))
comment.grid(row=4, column=1, columnspan=2, padx=10, pady=10)
  • You can also minimize or maximize the design of the main screen window in line with your choice and make it extra attractive.
  • When the above code is executed, let’s see the output of this code.

Output:

Complaint-Management-System-in-Python
Complaint-Management-System-in-Python

5. Create Table

This Module is for Creating a Table.

class ComplaintListing:
def __init__(self):
self.connectionDB = ConnectionDatabase()
self.connectionDB.row_factory = sqlite3.Row
self.root = Tk()
self.root.title('List of Complaints')
tree = Treeview(self.root)
tree.pack()
tree.heading('#0', text='ID')
tree.configure(column=('#FirstName', '#LastName', '#Address', '#Gender', '#Comment'))
tree.heading('#FirstName', text='First Name')
tree.heading('#LastName', text='Last Name')
tree.heading('#Address', text='Address')
tree.heading('#Gender', text='Gender')
tree.heading('#Comment', text='Comment')
tree.column('#0', stretch=NO, minwidth=0, width=100)
tree.column('#1', stretch=NO, minwidth=0, width=100)
tree.column('#2', stretch=NO, minwidth=0, width=100)
tree.column('#3', stretch=NO, minwidth=0, width=100)
tree.column('#4', stretch=NO, minwidth=0, width=100)
tree.column('#5', stretch=NO, minwidth=0, width=300)
cursor = self.connectionDB.ListRequest()
for row in cursor:
tree.insert('', 'end', '#{}'.format(row['ID']), text=row['ID'])
tree.set('#{}'.format(row['ID']), '#FirstName', row['FirstName'])
tree.set('#{}'.format(row['ID']), '#LastName', row['LastName'])
tree.set('#{}'.format(row['ID']), '#Address', row['Address'])
tree.set('#{}'.format(row['ID']), '#Gender', row['Gender'])
tree.set('#{}'.format(row['ID']), '#Comment', row['Comment'])

In the code above, This method will show you how to create a table in the complaint management system window.

When the above code is executed, it produces the following result below.

Complaint Management System List of Complaints
Complaint Management System List of Complaints

6. Complete Source Code

Complaint-System-Main.py

from tkinter import *
from tkinter.ttk import *
from tkinter.messagebox import *

from complaintListing import ComplaintListing
from configdb import ConnectionDatabase

#Config


conn = ConnectionDatabase()
root = Tk()
root.geometry('550x350')
root.title('Complaint Management System')
root.configure(bg='blue')

#Style


style = Style()
style.theme_use('classic')
for styles in ['TLabel', 'TButton', 'TRadioButton']:
style.configure(styles, bg='blue')


labels = ['First Name:', 'Last Name:', 'Address:', 'Gender:', 'Comment:']
for i in range(4):
Label(root, text=labels[i]).grid(row=i, column=0, padx=10, pady=10)


ButtonList = Button(root, text='View Complain')
ButtonList.grid(row=5, column=1)

ButtonSubmit = Button(root, text='Submit Now')
ButtonSubmit.grid(row=5, column=2)

# Entries
firstname = Entry(root, width=40, font=('Arial', 14))
firstname.grid(row=0, column=1, columnspan=2)

lastname = Entry(root, width=40, font=('Arial', 14))
lastname.grid(row=1, column=1, columnspan=2)

address = Entry(root, width=40, font=('Arial', 14))
address.grid(row=2, column=1, columnspan=2)

GenderGroup = StringVar()
Radiobutton(root, text='Male', value='male', variable=GenderGroup).grid(row=3, column=1)
Radiobutton(root, text='Female', value='female', variable=GenderGroup).grid(row=3, column=2)


comment = Text(root, width=40, height=5, font=('Arial', 14))
comment.grid(row=4, column=1, columnspan=2, padx=10, pady=10)

def SaveData():
message = conn.Add(firstname.get(), lastname.get(), address.get(), GenderGroup.get(), comment.get(1.0, 'end'))
firstname.delete(0,'end')
lastname.delete(0, 'end')
address.delete(0, 'end')
comment.delete(1.0, 'end')
showinfo(title='Add Information', message=message)

def ShowComplainList():

listrequest = ComplaintListing()


ButtonSubmit.config(command=SaveData)
ButtonList.config(command=ShowComplainList)

root.mainloop()

Configdb.py

import sqlite3

class ConnectionDatabase:
def __init__(self):
self._db = sqlite3.connect('complaintDB.db')
self._db.row_factory = sqlite3.Row
self._db.execute('create table if not exists complainTable(ID integer primary key autoincrement, FirstName varchar(255), LastName varchar(255), Address Text, Gender varchar(255), Comment text)')
self._db.commit()
def Add(self,firstname,lastname,address, gender,comment):
self._db.execute('insert into complainTable (FirstName, LastName, Address, Gender, Comment) values (?,?,?,?,?)', (firstname, lastname, address, gender, comment))
self._db.commit()
return 'Your complaint has been submitted.'
def ListRequest(self):
cursor = self._db.execute('select * from complainTable')
return cursor

ComplainListing.py

from tkinter import *
from tkinter.ttk import *
import sqlite3

from configdb import ConnectionDatabase


class ComplaintListing:
def __init__(self):
self.connectionDB = ConnectionDatabase()
self.connectionDB.row_factory = sqlite3.Row
self.root = Tk()
self.root.title('List of Complaints')
tree = Treeview(self.root)
tree.pack()
tree.heading('#0', text='ID')
tree.configure(column=('#FirstName', '#LastName', '#Address', '#Gender', '#Comment'))
tree.heading('#FirstName', text='First Name')
tree.heading('#LastName', text='Last Name')
tree.heading('#Address', text='Address')
tree.heading('#Gender', text='Gender')
tree.heading('#Comment', text='Comment')
tree.column('#0', stretch=NO, minwidth=0, width=100)
tree.column('#1', stretch=NO, minwidth=0, width=100)
tree.column('#2', stretch=NO, minwidth=0, width=100)
tree.column('#3', stretch=NO, minwidth=0, width=100)
tree.column('#4', stretch=NO, minwidth=0, width=100)
tree.column('#5', stretch=NO, minwidth=0, width=300)
cursor = self.connectionDB.ListRequest()
for row in cursor:
tree.insert('', 'end', '#{}'.format(row['ID']), text=row['ID'])
tree.set('#{}'.format(row['ID']), '#FirstName', row['FirstName'])
tree.set('#{}'.format(row['ID']), '#LastName', row['LastName'])
tree.set('#{}'.format(row['ID']), '#Address', row['Address'])
tree.set('#{}'.format(row['ID']), '#Gender', row['Gender'])
tree.set('#{}'.format(row['ID']), '#Comment', row['Comment'])

How To Run The Complaint Management System in Python with Source Code?

To run this project, you must have installed a Pycharm on your PC (for Windows). This Complaint Management System with Source Code is for educational purposes only!

After downloading the project you must follow the steps below:

Step 1: Unzip the file or Extract the file

Step 2: Double-click the Complaint-System-Main

Step 3: The project is ready to run

Downloadable Source Code

I have here the list of Best Python Projects with Source code free to download for free, I hope this can help you a lot.

Conclusion

This Complaint Management System Project in Python with Source Code is free to download.

A Complaint Management System contains the admin side only that can manage the information of a user and can easily view a list of complaints displaying the user’s first name, and last name with their id number, address, gender, and comments.

This project is good for the student who wants to learn Python programming because this project contains a Graphical User Interface (GUI) and a users friendly.

It is easy to understand and manipulate this project and use it for education purposes only.

1 thought on “Complaint Management System Project in Python Source Code”

Leave a Comment