Download as pdf or txt
Download as pdf or txt
You are on page 1of 69

Development of Online Voting System using Python

Project Report

Submitted to the Faculty of Engineering and Technology


in Partial Fulfillment of the Requirements for the Award of the Degree
of
Bachelor of Technology
in
Computer Science and Engineering
Submitted by
Harshdeep Kaur
(University Registration No. 21014103)

Department of Computer Science


Sri Guru Granth Sahib World University
Fatehgarh Sahib-140406, Punjab, India
May 2024
Department of Computer Science
Sri Guru Granth Sahib World University
Fatehgarh Sahib

CANDIDATE’S DECLARATION

I, Harshdeep Kaur, hereby certify that the work which is being presented in the project
report entitled “Development of Online Voting System using Python” in fulfillment of the
requirements for the award of the Degree of Bachelor of Technology in Computer Science &
Engineering and submitted in the Department of Computer Science of the Sri Guru Granth
Sahib World University, Fatehgarh Sahib is an authentic record of my own work carried out
by me during a period from January 2024-May 2024 under the supervision of “Dr. Sarpreet
Singh”, Assistant Professor Department of Computer Science of the Sri Guru Granth Sahib
World University, Fatehgarh Sahib.

The matter presented in this report has not been submitted by me for the award of any other
degree of this or any other Institute.

Harshdeep Kaur

This is to certify that the above statement made by the candidate is correct to the best of our
knowledge.

Dr. Sarpreet Singh


(Assitant Professor)

Date: 15 April 2024

ii
Abstract

Our Online Voting System, built with Python and MySQL, represents a pivotal advancement
in electoral technology. Accessible via a user-friendly web interface, voters can securely engage
with the platform from any internet-enabled device. Rigorous authentication protocols
guarantee the eligibility of participants, ensuring the integrity of the electoral process.
Developed using Python programming language and MySQL Database, this project offers a
user-friendly interface for voters to cast their votes remotely while ensuring the integrity and
confidentiality of the voting process. The system streamlines ballot casting through an intuitive
interface, facilitating efficient selection and submission of choices. The system features real-
time vote counting mechanisms to tally votes and determine election results accurately.
Administrators can monitor the progress of the election and view live updates on vote counts.
Leveraging the power of Python and the reliability of MySQL, the system automates the
intricate processes of vote counting and tabulation, delivering real-time and accurate results.
To fortify security, robust encryption techniques and comprehensive audit trails are
implemented, safeguarding the sanctity of the electoral data. The system can be scaled to
accommodate elections of varying sizes and complexities, making it suitable for use in diverse
electoral contexts. In sum, our system epitomizes a contemporary approach to voting, fostering
accessibility, transparency, and trust in the democratic process.

iii
Acknowledgment

Firstly, I would like to express my sincere gratitude Dr. Sarpreet Singh Assistant Professor,
Computer Science Department, for giving me an opportunity to do the project and providing
me all support and guidance which made me complete the project on time. I am extremely
grateful to her for providing such a nice support and guidance.

I my profound gratitude to our project guide Dr. Sarpreet Singh, who took keen interest on my
project work and guided me all along, till the completion of my project work by providing all
the necessary information for developing a good system.

I am thankful to and fortunate enough to get constant encouragement, support and guidance
from all Teaching staffs of Department of computer science which helped us in successfully
completing our project work. Also, I would like to extend our sincere regards to all the non-
teaching staff of department of computer science for their timely support.

Harshdeep Kaur
University Registration No.21014103

iv
Table Of Contents
Candidate’s Declaration …………………………….……………………………….…..……ii
Abstract……………………………………………………………………………...………..iii
Acknowledgement…………..…………………………………………………………...…....iv
Contents….……………………………………………………….……………………….…...v
List of Figures..….…………………………………………………………………………....vii
List of Tables…..……………………………………………………………………………..vii
Abbreviations………………………………………………………………………………..viii
Chapter 1 Introduction………………………………………………………………………...9
1.1 Background………………………………………………………………………..9
1.2 Objectives………………………………………………………………………...10
1.3 Voting System Architecture…...…………………………………………………12
Chapter 2 Literature Review……………………………………………………………...….14
2.1 Introduction…………………………………………………………………...….14
2.2 Similar System Comparison……………………………………………………...14
2.2.1 SecureVote……………………………………………………………..14
2.2.2 eBallot………………………………………………………………….14
2.2.3 SecurePoll………………………………………………………………15
2.3 Similar Tools Comparison……………………………………………………….15
Chapter 3 Methodology…………………………………………………………………...….16
3.1 Design…………………………………………………………………………….16
3.2 Behavioral View………………………………………………………………….17
3.2.1 Sequence Diagram……………………………………………………...17
3.2.2 Flowchart……………………………………………………………….18
3.2.3 Data Flow Diagram…………………………………………………….19
3.3 Tools and Technology………………………………………………………...….19
3.3.1 Python……………………………………………………………….….19
3.3.1.1 Introduction…………………………………….…………….19
3.3.1.2 History………………………….…………………………….20

v
3.3.1.3 Libraries……………………….……………………………..20
3.3.1.4 Tkinter Module……………………………….………………21
3.3.2 MySQL…………………………………………………………………21
3.3.2.1 Introduction…………………………………………………..21
3.3.2.2 Key Features and Benefits of MySQL………….……………22
Chapter 4 Implementation……………………………………………………………………23
4.1 Hardware Software Requirements………………………………………………………..23
4.1.1 Software Requirements………………………………………………………...23
4.1.2 Hardware Requirements………………………………………………………..23
4.2 Steps for Successful Implementation…………………………………………………….23
4.2.1 Steps to vote in online voting system……………………..……………………23
4.2.2 Steps to administer a voting system……………………………………………24
Chapter 5 Results and Discussion……………………………………………………………26
5.1 Results………………………………………………………................................26
5.2 Discussion………………………………………………………..........................27
Chapter 6 Conclusion………………………………………………………...........................28
References………………………………………………………............................................29
Appendices………………………………………………………...........................................30
Python code for Online Voting System………………………………………………30
Screenshots of the application………………………………………………..............63

vi
List of Tables and Figures

List of Tables
Figure 2-1: Similar Tools Comparsion…………………..…………………………………...15

List of Figures
Figure 1-1: Voting System Architecture…………..……………………..…………………...13
Figure 3-1: Sequence Diagram…………………………………………………...…………..17
Figure 3-2: Flowchart…………………………………...……………………………………18
Figure 3-3: Data Flow Diagram………………………………………………………………19
Figure8-1: Main Frame…………………………………...…………………………………..63
Figure8-2: Voter Dashboard...………………………………...……………………………...63
Figure8-3: Voter Registration…………………….…………...……………………………...64
Figure8-4: Voter Login…….…………………………………...…………………………….64
Figure8-5: Voting Frame………………………………………...…………………………...65
Figure8-6: Admin Frame……...…………………………………...…………………………65
Figure8-7: Admin Registration...……………………………...……………………………...66
Figure8-8: Admin Dashboard…..…………………………………...………………………..66
Figure8-9: Viewing All Records..…………………………...……………………………......67
Figure8-10: Searching User by Aadhar…….…………………………………...……………67
Figure8-11: Updating User by Aadhar……………………...……………………………......68
Figure8-12: Deleting User...………………………………...……………………………......68

vii
Abbreviations
API Application Programming Interface

GUI Graphics User Interface

HTTP Hypertext Transfer Protocol

MIME Multipurpose Internet Mail Extensions

OVS Online Voting System

PHP Hypertext Preprocessor

SETL SET Language

SQL Structured Query Language

SSL Secure Sockets Layer

TLS Transport Layer Security

viii
CHAPTER 1
Introduction

An online voting system is a software platform that enables groups to securely conduct votes
and elections. an online voting system using Python involves leveraging the language's
versatility and numerous libraries to create a secure, efficient, and user-friendly platform for
digital ballot casting. Python's flexibility makes it well-suited for building both the front-end
interface and the back-end logic of such a system. At its core, an online voting system in Python
would involve developing a web application utilizing frameworks like Django or Flask for the
back-end infrastructure. These frameworks provide tools for handling user authentication,
managing databases, and implementing secure communication protocols, essential components
for ensuring the integrity of the voting process.

On the front end, Python can be used in conjunction with libraries like Flask or Django
templates, or even JavaScript frameworks like React or Vue.js for dynamic user interfaces.
These interfaces would allow voters to access the system securely, navigate through ballot
options, and cast their votes intuitively. Python's extensive ecosystem also offers libraries for
implementing cryptographic protocols, ensuring the confidentiality and integrity of votes
during transmission and storage. Techniques like end-to-end encryption and digital signatures
can be employed to safeguard voter privacy and prevent tampering with ballot data.
Furthermore, Python's scalability allows for the system to accommodate various voting
methods and scale up to handle large volumes of concurrent users during peak voting periods.
Cloud services like AWS or Azure can be utilized for hosting and deploying the application,
ensuring reliable performance and availability.

Overall, Python provides a powerful toolkit for developing an online voting system that
prioritizes security, usability, and scalability, making it a compelling choice for modernizing
electoral processes in the digital age.

1.1 Background

The concept of an online voting system stems from the broader aim of leveraging technology
to modernize and streamline democratic processes. Traditional paper-based voting systems
have long been the cornerstone of democratic elections, but they often face challenges such as
Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

logistical complexities, high costs, and limited accessibility. In response, the idea of moving
voting procedures to an online platform emerged as a potential solution to address these issues
and enhance the electoral process in several ways. The background of online voting systems
can be traced back to the late 20th century when the internet began to gain widespread adoption.
The initial attempts aimed to explore the feasibility of digitizing the voting process and assess
the potential benefits and challenges associated with it. Over the years, advancements in
technology and cybersecurity have paved the way for more sophisticated online voting systems
capable of ensuring the security, privacy, and integrity of digital ballots. Governments,
electoral commissions, and private organizations worldwide have increasingly shown interest
in adopting online voting as a means to enhance voter participation, streamline administrative
processes, and adapt to the digital age.

However, the widespread adoption of online voting systems has been met with various debates
and challenges. Concerns about cybersecurity vulnerabilities, potential for fraud, and the need
to maintain voter anonymity have raised questions about the reliability and trustworthiness of
these systems. Additionally, ensuring accessibility for all voters, including those with
disabilities or limited access to technology, remains a significant consideration in the design
and implementation of online voting systems. Despite these challenges, ongoing research and
development efforts continue to explore ways to address the concerns surrounding online
voting and improve the security and usability of these systems. As technology evolves and
society becomes increasingly interconnected, online voting is likely to remain a topic of interest
and innovation in the realm of democratic governance.

1.2 Objectives

The objectives of an online voting system encompass various goals aimed at enhancing the
electoral process, increasing accessibility, and ensuring the integrity and security of the voting
process.

Some key objectives include:

• Enhancing Accessibility: Online voting systems aim to make the electoral process more
accessible to voters by allowing them to cast their ballots remotely from anywhere with
an internet connection. This accessibility can benefit individuals who face mobility

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 10


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

challenges, live in remote areas, or are unable to participate in traditional in-person


voting due to various reasons.
• Increasing Voter Turnout: By providing a convenient and flexible voting option, online
voting systems seek to increase voter turnout. The ability to vote from the comfort of
one's home or on-the-go may encourage individuals who would otherwise abstain from
voting to participate in the electoral process.
• Streamlining Administration: Online voting systems aim to streamline the
administrative aspects of elections by reducing the need for paper-based processes,
manual counting, and physical polling stations. This can lead to cost savings, improved
efficiency, and faster results reporting.
• Ensuring Security and Integrity: One of the primary objectives of online voting systems
is to ensure the security and integrity of the voting process. This includes implementing
robust authentication mechanisms to verify the identity of voters, encrypting ballot data
to protect confidentiality, and implementing safeguards against tampering, hacking, or
fraudulent activities.
• Providing Accessibility Features: Online voting systems should be designed to
accommodate diverse needs and preferences, including those of voters with disabilities.
This involves providing accessibility features such as screen readers, alternative input
methods, and user-friendly interfaces that adhere to accessibility standards.
• Increasing Transparency: Online voting systems aim to increase transparency in the
electoral process by providing mechanisms for voters to verify that their votes have
been recorded accurately and counted correctly. This may include providing digital
receipts or audit trails that allow voters to verify their participation and ensure the
integrity of the overall election results.
• Adapting to Technological Advancements: As technology evolves, online voting
systems should be designed to adapt to new advancements and address emerging
cybersecurity threats. This involves staying abreast of technological developments,
implementing best practices in cybersecurity, and regularly updating and improving
system infrastructure and protocols.

Overall, the objectives of an online voting system center around improving the accessibility,
efficiency, security, and transparency of the electoral process, ultimately enhancing democracy
and civic engagement.

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 11


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

1.3 Voting system Architecture

Designing the architecture of an online voting system using Python involves structuring the
system into different layers or components, each responsible for specific functionalities. Here's
an overview of the architecture along with the Python technologies commonly used for each
component:

• Presentation Layer:

- This layer handles the user interface and interaction with voters.
- Technologies: HTML, CSS, JavaScript (for front-end development), and
Python frameworks like Django or Flask for rendering dynamic web pages.

• Application Layer:

- This layer contains the business logic of the online voting system, including
user authentication, ballot creation, vote casting, and result computation.
- Technologies: Python frameworks like Django or Flask for defining application
logic, handling HTTP requests, and interacting with the database.

• Data Layer:

- This layer manages the storage and retrieval of data related to users, candidates,
ballots, and voting results.
- Technologies: SQL databases such as PostgreSQL, MySQL, or SQLite, with
Python libraries like psycopg2 or SQL Alchemy for database interactions.

• Security Layer:

- This layer ensures the security and integrity of the online voting system,
including user authentication, data encryption, and protection against various
security threats.
- Technologies: Python libraries for implementing security features such as
cryptography for encryption, bcrypt for password hashing, and Django's built-
in authentication system for user management.

• Integration Layer:

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 12


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

- This layer facilitates integration with external systems or services, such as voter
registration databases, identity verification services, or third-party
authentication providers.
- Technologies: Python libraries for making HTTP requests (e.g., requests
library), and integration with external APIs using REST or SOAP protocols.

• Infrastructure Layer:

- This layer comprises the underlying infrastructure components required to


deploy and run the online voting system, including web servers, application
servers, and hosting platforms.
- Technologies: Deployment tools like Docker for containerization, Nginx or
Apache for web server, and cloud platforms like AWS, Google Cloud, or
Microsoft Azure for hosting.

Here's a simplified diagram illustrating the architecture:

Figure 1-1: Voting System Architecture

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 13


CHAPTER 2

Literature Review

2.1 Introduction

The evolution of Online Voting Systems can be traced back to the early experiments and
research conducted in the 1990s. Initial attempts focused on exploring the feasibility and
technical challenges of conducting elections electronically, with early implementations
utilizing simple web-based interfaces and rudimentary security measures.

Over time, advancements in technology, cryptography, and cybersecurity have led to the
development of more sophisticated OVS solutions capable of ensuring the integrity,
confidentiality, and accessibility of the voting process. Modern OVS platforms leverage
encryption, multi-factor authentication, and blockchain technology to enhance security and
transparency.

2.2 Similar Systems Comparison

2.2.1 SecureVote

SecureVote is an online voting system developed using Python with the Django web
framework. It prioritizes security by implementing end-to-end encryption, cryptographic
proofs, and blockchain technology to ensure the integrity and confidentiality of the voting
process. The system offers user authentication through multi-factor methods and guarantees
voter anonymity while maintaining comprehensive audit logs for transparency. SecureVote is
designed for horizontal scalability and complies with electoral regulations, being an open-
source project. It provides a user-friendly interface and robust security features, making it a
reliable choice for conducting elections electronically.

2.2.2 eBallot

eBallot is a proprietary online voting system developed in Java with the Spring framework. It
emphasizes security through the use of public-key cryptography, digital signatures, and
blockchain technology. The system offers multi-factor authentication and ensures voter
anonymity, with transaction logging for auditability. While eBallot provides vertical
scalability and cloud deployment options, it is not open-source. However, its comprehensive
Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

security measures and user-friendly interface make it suitable for various electoral contexts,
ensuring the integrity and transparency of the voting process.

2.2.3 SecurePoll

SecurePoll is an open-source online voting system built with Ruby on Rails. It prioritizes
security by implementing two-factor authentication, SSL/TLS encryption, and biometric
authentication. The system ensures voter anonymity and maintains audit trails for
transparency and accountability. SecurePoll is designed for horizontal scalability and offers
cloud deployment options, making it suitable for elections of varying sizes. Its open-source
nature allows for community contributions and collaboration, promoting innovation and
ensuring compliance with electoral regulations.

2.3 Similar Tools Comparison

Table below shows a comparison between our proposed system tool and other voting system
tools.

Figure 2-1: Similar Tools Comparison

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 15


CHAPTER 3
Methodology

3.1 Design

Designing an online voting system using Python and MySQL involves several steps. The
design of our proposed system encompasses various aspects, including architectural design,
database design, user interface design, and security design. Each aspect is crucial for ensuring
the functionality, usability, and security of the system.

1. Architectural Design:

The proposed system follows a client-server architecture, where the client-side application is
responsible for user interaction and the server-side application manages data storage, retrieval,
and processing.

2. Database Design:

For data storage, the system utilizes a relational database management system (RDBMS) with
MySQL as the backend database. The database schema is designed to efficiently store and
organize various types of data, including user profiles, voting records, candidate information,
and system configurations. Normalization techniques are applied to minimize redundancy and
ensure data integrity.

3. User Interface Design:

The user interface of the system is designed using the Tkinter module in Python, providing a
graphical interface for users to interact with the system. The interface is intuitive, user-friendly,
and responsive, with clear navigation and informative feedback messages. It includes features
such as voter registration, candidate selection, ballot submission, and result viewing, presented
in a visually appealing manner.

4. Security Design:

Security is a paramount concern in the design of the system. Various security measures are
implemented to protect the integrity, confidentiality, and availability of data. These measures
include end-to-end encryption for data transmission, secure user authentication using
username/password control mechanisms to restrict unauthorized access to sensitive data.
Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

5. Integration and Compatibility:

The system is designed to be easily integrable with existing systems and compatible with
different platforms and devices. APIs are provided for seamless integration with external
systems, allowing for data exchange and interoperability. Compatibility testing is conducted to
ensure the system functions correctly across various operating systems, web browsers, and
devices.

3.2 Behavioral View

Flowchart, and sequence diagram provide the behavioral view for our project. Behavioral
diagrams are used to describe the interaction between the actors and the system. All the
activities that are performed by the actors and the system are introduced in some way.

3.2.1 Sequence Diagram

A sequence diagram shows object interactions arranged in time sequence. It depicts the objects
and classes involved in the scenario and the sequence of messages exchanged between the
objects needed to carry out the functionality of the scenario.

Figure 3-1: Sequence Diagram

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 17


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

3.2.2 Flowchart

Figure 3-2: Flowchart for Voter Login

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 18


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

3.2.3 Data Flow Diagram

A data flow diagram (DFD) is a graphical representation of the "flow" of data through an
information system, modeling its process aspects. Often they are a preliminary step used to
create an overview of the system which can later be elaborated. DFDs can also be used for
the visualization of data processing (structured design). A DFD shows what kinds of
information will be input to and output from the system, where the data will come from and
go to, and where the data will be stored. It does not show information about the timing of
processes, or information about whether processes will operate in sequence or in parallel.

Figure 3-3: Data Flow Diagram

3.3 Tools and Technologies

• Front-end Programming Language: Python

• Back-end Programming Language: MySQL

3.3.1 Python

3.3.1.1 Introduction
In this project, “Hospital Management System” we have used the Python language. Python is
a high-level, general-purpose programming language. Its design philosophy emphasizes code
readability with the use of significant indentation. Python is dynamically typed and garbage-
collected. It supports multiple programming paradigms, including structured (particularly

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 19


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

procedural), object-oriented and functional programming. It is often described as a "batteries


included" language due to its comprehensive standard library.

3.3.3.2 History

Python was conceived in the late 1980s by Guido van Rossum at Centrum Wiskunde &
Informatica (CWI) in the Netherlands as a successor to the ABC programming language, which
was inspired by SETL, capable of exception handling and interfacing with the Amoeba
operating system. Its implementation began in December 1989, Van Rossum shouldered sole
responsibility for the project, as the lead developer, until 12 July 2018, when he announced his
"permanent vacation" from his responsibilities as Python's "benevolent dictator for life", a title
the Python community bestowed upon him to reflect his long-term commitment as the project's
chief decision-maker.

3.3.3.3 Libraries

Python's large standard library provides tools suited to many tasks and is commonly cited as
one of its greatest strengths. For Internet-facing applications, many standard formats and
protocols such as MIME and HTTP are supported. It includes modules for creating graphical
user interfaces, connecting to relational databases, generating pseudorandom numbers,
arithmetic with arbitrary-precision decimals, manipulating regular expressions, and unit
testing. As of 14 November 2022, the Python Package Index (PyPI), the official repository for
third-party Python software, contains over 415,000 packages with a wide range of
functionality, including:

➢ Automation

➢ Data Analytics

➢ Databases

➢ Documentation

➢ Graphical User Interfaces

➢ Image Processing

➢ Machine Learning

➢ Mobile Apps

➢ Multimedia

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 20


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

➢ Computer Networking

➢ Scientific Computing

➢ System Administration

➢ Test Frameworks

➢ Text Processing

➢ Web Frameworks

➢ Web Scraping

• GUI Library: Tkinter

3.3.3.4 Tkinter Module

Tkinter is a standard python interface to the Tk GUI toolkit shipped with python. Python
Tkinter is the fastest and easiest way to create GUI applications. Developing desktop -
based applications with python Tkinter is not a complex task. An empty Tkinter top-
level window can be created by using the following steps:

➢ Import the Tkinter module.

➢ Create the main applications window.

➢ Add the widgets like labels, buttons, frames, etc. to the window.

➢ Call the main event loop so that the cations can take place on the user’s
computer screen.

3.3.2 MySQL

3.3.2.1 Introduction

MySQL is a popular open-source relational database management system (RDBMS) that is


widely used for storing, managing, and retrieving data in various applications, including web-
based systems like the Online Voting System. MySQL is known for its reliability, performance,
scalability, and ease of use, making it an ideal choice for managing the backend database of
the Online Voting System.

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 21


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

3.3.2.2 Key Features and Benefits of MySQL:

1. Relational Database: MySQL is a relational database management system, which means it


organizes data into tables with rows and columns, allowing for efficient data storage and
retrieval. This relational model is well-suited for the structured data requirements of the Online
Voting System, where information about voters, candidates, ballots, and election results needs
to be stored and managed.

2. Data Integrity: MySQL provides robust mechanisms for ensuring data integrity, including
support for primary keys, foreign keys, unique constraints, and check constraints. These
features help enforce data consistency and prevent the insertion of invalid or duplicate data into
the database, ensuring the accuracy and reliability of the voting system's data.

3. Transaction Support: MySQL supports transactions, allowing multiple database operations


to be grouped together as a single unit of work. This ensures that all operations within a
transaction are either completed successfully or rolled back in case of failure, maintaining the
integrity and consistency of the database. Transactions are essential for handling complex
operations in the Online Voting System, such as updating voter information, casting votes, and
generating election reports.

4. Scalability: MySQL is designed to scale vertically and horizontally to accommodate


increasing data volumes and user traffic. Vertical scalability involves adding more resources
to a single server, such as CPU, memory, and storage, while horizontal scalability involves
distributing data across multiple servers. This scalability ensures that the Online Voting System
can handle large-scale elections with a high number of voters and candidates without
compromising performance or reliability.

5. Security: MySQL offers robust security features to protect sensitive data stored in the
database. These features include user authentication, access control, encryption, and auditing
capabilities. By implementing proper security measures, the Online Voting System can
safeguard voter information, election data, and system configurations from unauthorized
access, tampering, or breaches.

6. Compatibility: MySQL is compatible with various programming languages, frameworks,


and platforms, making it easy to integrate with different components of the Online Voting
System. Whether the system is developed using Python, Java, PHP, or any other programming
language, MySQL provides drivers and libraries for seamless interaction with the database.

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 22


CHAPTER 4
Implementation

An online voting system using Python and MySQL involves developing a web
application that enables users to securely register, log in, view candidate options, and cast their
votes. Python serves as the backend language, managing the logic of user authentication, data
validation, and database interaction. MySQL is utilized to store user information, candidate
details, and voting records. It provides intuitive interfaces for users to navigate the voting
process. Security measures, including encryption for sensitive data and safeguards against SQL
injection, are integrated to ensure the integrity of the system. Once deployed, the system allows
for efficient vote tallying and result dissemination while upholding the confidentiality and
accuracy of the electoral process. Testing and deployment phases ensure the system's reliability,
scalability, and resistance to potential vulnerabilities.

4.1 Hardware and Software Requirements

4.1.1 Software Requirements

(i) Operating System: Windows 7 or higher

(ii) Coding Interface: Microsoft Visual Studio 2010 or higher

MySQL 8.0 or higher

4.1.2 Hardware Requirements

(i) Processor: 1.0MHZ or higher

(ii) Hard Disk Capacity: 150GB or higher

(iii) RAM: 2GB or higher

4.2 Steps for Successful Implementation

4.2.1 Steps to vote in online voting system:

1. Registration:

- Visit the registration page of the online voting system.


- Fill out the registration form with required details such as name, email, and password.
- Submit the form to create a new user account.
Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

- The system should validate the input data and ensure that the email address is unique.

2. Login:

- Navigate to the login page.


- Enter your registered email and password.
- Submit the login form.
- The system authenticates your credentials against the stored user data.
- Upon successful authentication, you are redirected to the dashboard or the voting page.

3. Submit Vote:

- After selecting the candidate, confirm your choice.


- Click the "Vote" or "Submit" button to cast your vote.
- The system records your vote securely in the database.
- Ensure that you can only vote once to maintain the integrity of the election.

4.2.2 Steps to administer a voting system:

1. Admin Registration:

- Implement a separate registration page specifically for administrators.


- Create a registration form for admin users with fields such as name, email, password, and
any additional relevant information.
- Validate the input data to ensure its integrity and uniqueness.
- Upon successful registration, store the admin's credentials securely in the database.

2. Admin Login:

- Develop an admin login page where administrators can enter their registered email and
password.
- Implement authentication logic to verify the provided credentials against the stored admin
data.
- Upon successful login, grant access to the admin dashboard or control panel.

3. Admin Dashboard:

- Design a dashboard interface specifically tailored for administrators.


- Provide options and functionalities such as checking the status of votes, managing
candidate data, viewing election statistics, etc.

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 24


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

- On the dashboard or the voting page, you can view the list of candidates participating in
the election.
- Each candidate may have a brief description or profile.
- Review the profiles of the candidates and make an informed decision.
- Click on the checkbox or button associated with your preferred candidate.

4. Check Full Status of Votes:

- Within the admin dashboard, include a section or page dedicated to viewing the full status
of votes.
- Implement functionality to query the database and retrieve all vote records.
- Display relevant information such as the total number of votes cast, votes for each
candidate, voter demographics, etc.
- Present the data in a clear and understandable format, such as tables, charts, or graphs,
for easy analysis.

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 25


CHAPTER 5
Results and Discussion

This online voting system allows users to register, login securely, vote for candidates, and
provides administrators with tools to manage elections and monitor voting activity. It ensures
the integrity of the electoral process through validation checks, encryption, and secure storage
of data. Users can access the system from any internet-enabled device, facilitating convenient
and efficient participation in elections while maintaining confidentiality and accuracy. Admins
can track and analyze voting trends, ensuring transparency and accountability in the electoral
process.

5.1 Results

Sure, here's an example of what you could include in the "Results" section of a project report
for an online voting system:

1. User Engagement and Participation

During the testing phase of the online voting system, we observed significant user engagement
and participation. The high level of engagement indicates a strong acceptance of the online
voting system among our target demographic.

2. System Performance and Stability

The online voting system demonstrated robust performance and stability throughout the testing
period. The reliability is crucial for ensuring the integrity and trustworthiness of the voting
process.

3. Security Measures and Vulnerability Assessment

Security is a top priority for any voting system, especially one operating online. To ensure the
integrity of the voting process, we implemented multiple security measures, including
encryption protocols, user authentication mechanisms, and secure data storage practices.
Additionally, we conducted thorough vulnerability assessments and penetration tests to identify
and mitigate any potential security risks. The results of these assessments confirmed that the
online voting system is highly resilient to external threats and unauthorized access.

4. Voter Satisfaction and Feedback


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

The majority of respondents expressed satisfaction with the user interface, ease of navigation,
and overall voting process. However, some users provided suggestions for improvement, such
as adding additional voting options or enhancing the accessibility features of the platform. We
will take these suggestions into consideration for future iterations of the system.

5. Compliance with Regulatory Standards

Our online voting system was designed to comply with relevant regulatory standards and
guidelines governing electronic voting processes. The system has been designed to facilitate
auditing and verification processes to uphold the integrity of the voting process and ensure
adherence to regulatory standards.

5.2 Discussion

Online voting systems offer convenience and accessibility but raise significant concerns
regarding security and integrity. While Python's versatility enables developers to create user-
friendly interfaces and robust backend logic, ensuring the protection of sensitive voter data and
preventing fraud remains paramount. Implementing encryption, stringent authentication
measures, and regular security audits are vital to safeguard against cyber threats and maintain
trust in the electoral process. Additionally, addressing challenges such as voter authentication,
ballot secrecy, and auditing mechanisms is essential to ensure fairness and transparency. While
online voting systems offer the potential for increased voter participation and streamlined
elections, careful consideration of security risks and rigorous testing are imperative to mitigate
potential vulnerabilities and uphold the democratic principles of accuracy, confidentiality, and
fairness.

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 27


CHAPTER 6
Conclusion

The project of an online voting system using Python and MySQL achieves several
significant outcomes. Firstly, it provides a platform for users to conveniently participate in
elections from anywhere with internet access, thereby increasing voter accessibility and
engagement. Secondly, it establishes a secure and reliable system for storing and managing
voting data using MySQL, ensuring the integrity and confidentiality of the electoral process.
Additionally, the project demonstrates the potential of Python's versatility in developing user-
friendly interfaces and robust backend functionalities, contributing to advancements in digital
democracy.

Developing an online voting system offers a vast potential for user engagement and future
advancements. Python's versatility enables the creation of intuitive user interfaces and robust
backend functionalities, while MySQL provides a reliable database management solution for
storing critical voting data securely. As technology continues to evolve, the future of online
voting systems built with Python and MySQL holds promise in revolutionizing the electoral
process, fostering greater accessibility and participation among voters. By prioritizing security,
transparency, and user experience, this project application paves the way for innovative
solutions that empower users to exercise their democratic rights effectively in the digital era.
Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

References
1. Python Crash Course: A Hands-on, Project-Based Introduction to programming by
Eric Matthes(1972)

2. Python GUI Programming with Tkinter: Design and buid functional and user-friendly
GUI applications by Alan D. Moore(2018)

3. MySQL Connector/Python Revealed: SQL and NoSQL Data Storage using MySQL
for Python Programmers by Jesper Wisborg Krogh

4. Python Software Foundation. (https://www.python.org/)

5. Tkinter Documentation. (https://docs.python.org/3/library/tkinter.html)

6. MySQL Documentation. (https://www.mysql.com)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 29


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

Appendices
• Python code for Application.

from tkinter import *


from PIL import ImageTk, Image
from tkinter import messagebox
from tkinter.ttk import Combobox
from settings import *
import database as model
import webbrowser

root = Tk()
root.geometry("900x600")
root.resizable(0, 0)
root.title("Voting Machine")
root.iconbitmap('E:\PYTHON PROGRAMS\icon.ico')
root.configure(background="white")

homeImg = ImageTk.PhotoImage(Image.open("E:\PYTHON
PROGRAMS\homeImg.jpg"))

model.connect()

def voterLogin():
voterId = StringVar()
global loginFrame,show_image3,hide_image3,vpassword
loginFrame = Frame()
loginFrame.place(x=0, y=0, width="500", height="600")
loginFrame.configure(background="white")

label = Label(loginFrame, text="Login to Vote", font=(ARIAL, 20, "bold"),


bg="white", fg=HIGHLIGHT_TEXT)
label.place(x=150, y=50)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 30


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

label0 = Label(loginFrame, text="Voter Id ", font=(ARIAL, 12, "normal"),


bg="white")
label0.place(x=100, y=150)
input0 = Entry(loginFrame, font=(ARIAL, 12), textvariable=voterId, border=0,
bg="#f0f0f0")
input0.place(x=200, y=150, width="200", height="25")

vpassword_label = Label(loginFrame, text="Password",


font=(ARIAL, 13))
vpassword_label.place(x=100, y=200)

vpassword = Entry(loginFrame, highlightthickness=0, relief=FLAT, bg="#f0f0f0",


font=(ARIAL, 12), show="*", insertbackground = '#6b6a69')
vpassword.place(x=200, y=200, width=200)

# ========= show/hide password


================================================================
==
show_image3 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\show.png')

hide_image3 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\hide.png')

show_button3 = Button(loginFrame, image=show_image3, command=show3,


relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
show_button3.place(x=410, y=200)

def Login():
if(voterId.get() == ""):
messagebox.showwarning('Voting System Message', 'Field are required')

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 31


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

else:
result = model.findByVoterId(voterId.get())
voter_password=model.check_voter_password(voterId.get())
print(voter_password)
if(result == None):
messagebox.showerror('Voting System Message', 'Wrong Credentials')
elif (voter_password[0] != (vpassword.get())):
messagebox.showerror("Error","Wrong Password")
else:
dashboard(voterId.get())

voterId.set("")

Login_btn = Button(loginFrame, text="Login", font=(ARIAL, 13, "bold"),


command=Login, border=0, bg=HIGHLIGHT_BG, fg="white")
Login_btn.place(x=200, y=250, width=100, height=50)
back_btn = Button(loginFrame, text="< Back", font=(ARIAL, 10, "normal"),
command=VoterHome, border=0, bg="white", fg="grey")
back_btn.place(x=0, y=0, width=100, height=50)

def dashboard(voterId):
poll = StringVar()
district = StringVar()
name = StringVar()
state = StringVar()
DashboardFrame = Frame()
DashboardFrame.place(x=0, y=0, width=900, height=500)
DashboardFrame.configure(background="white")

result = model.findByVoterId(voterId)
name.set(result[2])

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 32


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

IDLabel = Label(DashboardFrame, text=voterId, font=(ARIAL, 13, "normal"),


bg="white", fg=HIGHLIGHT_TEXT)
IDLabel.place(x=10, y=10)

label = Label(DashboardFrame, text="Your Vote, Your Voice",


font=(LUCIDA_CONSOLE, 30, "bold"), bg="white", fg=HIGHLIGHT_BG)
label.place(x=175, y=50)

nameLabel = Label(DashboardFrame, text="Hi, "+name.get(), font=(ARIAL, 15,


"normal"), bg="white")
nameLabel.place(x=75, y=150)

pollLabel = Label(DashboardFrame, text="Select your poll ", font=(ARIAL, 15,


"normal"), bg="white")
pollLabel.place(x=200, y=225)
pollInput = Combobox(root, values=["BJP", "TMC","SP","AAP"], font=(ARIAL, 13,
"normal"), textvariable=poll)
pollInput.place(x=400, y=225, width=200)
districtLabel = Label(DashboardFrame, text="Select your District", font=(ARIAL, 15,
"normal"), bg="white")
districtLabel.place(x=200, y=275)
districtInput = Combobox(root,
values=["Amritsar","Barnala","Bathinda","Faridkot","Fatehgarh Sahib",
"Fazilka","Ferozepur","Gurdaspur","Hoshiarpur","Jalandhar",
"Kapurthala","Ludhiana","Mansa","Moga","Mohali","Muktsar
",
"Nawanshahr","Pathankot","Patiala","Ropar","Rupnagar",
"Sangrur","Tarn Taran"], font=(ARIAL, 13, "normal"),
textvariable=district)
districtInput.place(x=400, y=275, width=200)
labela = Label(DashboardFrame, text="State", font=(ARIAL, 15, "normal"),
bg="white")
labela.place(x=200, y=325)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 33


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

inputa = Entry(DashboardFrame, font=(ARIAL, 12), textvariable=state, border=0,


bg="#f0f0f0")
inputa.place(x=400, y=325, width="200", height="25")

def Vote():
if poll.get()=="" or district.get()=="" or state.get()=="":
messagebox.showwarning('Voting System Message','all field are required')

else:
result1 = model.findByVoterIdinVote(voterId)
if(result1 == None):
if model.submitVote(voterId, poll.get(), state.get(), district.get()):
messagebox.showinfo('Voting System Message', 'Thanks, Vote submited
succefully')

else:
messagebox.showwarning('Voting System Message', 'Try again later, Failed
to vote')

else:
messagebox.showwarning('Voting System Message', 'Thanks, but you have
voted already')

poll.set("")
state.set("")
district.set("")
name.set("")
logout()

Vote_btn = Button(DashboardFrame, text="Vote", font=(ARIAL, 13, "normal"),


command=Vote, border=0, bg=HIGHLIGHT_BG, fg="white")
Vote_btn.place(x=375, y=375, width=150, height=50)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 34


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

logOut = Button(DashboardFrame, text="Log Out", font=(ARIAL, 10, "normal"),


command=logout, border=0, bg="white", fg="grey")
logOut.place(x=800, y=0, width=100, height=50)

def voterRegistration():
global
RegistrationFrame,password,confirm_password,show_image1,show_image2,hide_image
1,hide_image2
voterId = StringVar()
name = StringVar()
age=IntVar()
aadhar = StringVar()
phone = StringVar()
gender = StringVar()
# password = StringVar()
# confirm_password = StringVar()
RegistrationFrame = Frame()
RegistrationFrame.place(x=0, y=0, width="500", height="600")
RegistrationFrame.configure(background="white")

label = Label(RegistrationFrame, text="Register to Vote", font=(ARIAL, 20, "bold"),


bg="white", fg=HIGHLIGHT_TEXT)
label.place(x=125, y=50)

label0 = Label(RegistrationFrame, text="Voter Id ", font=(ARIAL, 12, "normal"),


bg="white")
label0.place(x=30, y=125)
input0 = Entry(RegistrationFrame, font=(ARIAL, 12), textvariable=voterId, border=0,
bg="#f0f0f0")
input0.place(x=250, y=125, width="200", height="25")

label1 = Label(RegistrationFrame, text="Full Name ", font=(ARIAL, 12, "normal"),


bg="white")

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 35


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

label1.place(x=30, y=175)
input1 = Entry(RegistrationFrame, font=(ARIAL, 12), textvariable=name, border=0,
bg="#f0f0f0")
input1.place(x=250, y=175, width="200", height="25")

labela = Label(RegistrationFrame, text="Age ", font=(ARIAL, 12, "normal"),


bg="white")
labela.place(x=30, y=225)
inputa = Entry(RegistrationFrame, font=(ARIAL, 12), textvariable=age, border=0,
bg="#f0f0f0")
inputa.place(x=250, y=225, width="200", height="25")

label2 = Label(RegistrationFrame, text="Aadhar Card Number", font=(ARIAL, 12,


"normal"), bg="white")
label2.place(x=30, y=275)
input2 = Entry(RegistrationFrame, font=(ARIAL, 12), textvariable=aadhar, border=0,
bg="#f0f0f0")
input2.place(x=250, y=275, width="200", height="25")

label3 = Label(RegistrationFrame, text="Mobile Number", font=(ARIAL, 12,


"normal"), bg="white")
label3.place(x=30, y=325)
input3 = Entry(RegistrationFrame, font=(ARIAL, 12), textvariable=phone, border=0,
bg="#f0f0f0")
input3.place(x=250, y=325, width="200", height="25")

label4 = Label(RegistrationFrame, text="Gender ", font=(ARIAL, 12, "normal"),


bg="white")
label4.place(x=30, y=375)
input4=Combobox(RegistrationFrame, values=["Male","Female"], font=(ARIAL, 12,
"normal"), textvariable=gender, background="#f0f0f0")
input4.place(x=250, y=375, width="200", height="25")

password_label1 = Label(RegistrationFrame, text="Password",

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 36


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

font=(ARIAL, 13))
password_label1.place(x=30, y=425)

password = Entry(RegistrationFrame, highlightthickness=0, relief=FLAT,


bg="#f0f0f0",
font=(ARIAL, 12), show="*", insertbackground = '#6b6a69')
password.place(x=250, y=425, width=200)

# ========= show/hide password


================================================================
==
show_image1 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\show.png')

hide_image1 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\hide.png')

show_button1 = Button(RegistrationFrame, image=show_image1, command=show1,


relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
show_button1.place(x=452, y=426)

confirm_password_label1 = Label(RegistrationFrame, text="Confirm Password",


font=(ARIAL, 13))
confirm_password_label1.place(x=30, y=475)

confirm_password = Entry(RegistrationFrame, highlightthickness=0, relief=FLAT,


bg="#f0f0f0",
font=(ARIAL, 12), show="*", insertbackground = '#6b6a69')
confirm_password.place(x=250, y=475, width=200)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 37


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

# ========= show/hide password


================================================================
==
show_image2 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\show.png')

hide_image2 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\hide.png')

show_button2 = Button(RegistrationFrame, image=show_image2, command=show2,


relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
show_button2.place(x=452, y=476)

def Register():
if voterId.get() == "" or name.get() == "" or age.get()=="" or aadhar.get() == "" or
phone.get() == "" or gender.get() == "":
messagebox.showwarning('Voting System Message', 'All field is requird')
elif int(age.get())<18:
messagebox.showerror("Error","You are not eligible to vote")
Home()
elif password.get() != confirm_password.get():
messagebox.showerror("Error", "Passwords do not match")
elif not is_valid_password(password.get()) or not
is_valid_password(confirm_password.get()):
messagebox.showerror("Error", "Passwords must meet the complexity
requirements")
else:
if len(aadhar.get()) == 12 and str(age.get()).isdigit() and len(phone.get()) == 10
and aadhar.get().isdigit() and phone.get().isdigit():
result = model.findByAadhar(aadhar.get())
result1 = model.findByVoterId(voterId.get())
model.add_voter_password(voterId.get(), password.get())

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 38


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

if((result == None) and (result1 == None)):


if model.addVoter(voterId.get(), name.get(),age.get(), aadhar.get(),
phone.get(), gender.get()):
messagebox.showinfo('Voting System Message', 'Registered as Voter')
voterId.set("")
name.set("")
age.set("")
aadhar.set("")
phone.set("")
gender.set("")
voterLogin()

else:
messagebox.showwarning('Voting System Message', 'Try again later,
Failed to register')

else:
messagebox.showerror('Voting System Message', 'Wrong
Credentials')

else:
messagebox.showerror('Voting System Message', 'Aadhar number must be 12
digit and Mobile number must be 10 digit')

Register_btn = Button(RegistrationFrame, text="Register", font=(ARIAL, 13, "bold"),


command=Register, border=0, bg=HIGHLIGHT_BG, fg="white")
Register_btn.place(x=150, y=525, width=200, height=50)
back_btn = Button(RegistrationFrame, text="< Back", font=(ARIAL, 10, "normal"),
command=VoterHome, border=0, bg="white", fg="grey")
back_btn.place(x=0, y=0, width=100, height=50)

def is_valid_username(username):
# Check length

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 39


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

if len(username) < 4 or len(username) > 20:


return False
# Check character set
if not username.isalnum():
return False
# Additional checks if needed (e.g., uniqueness)
return True

def is_valid_password(password):
# Check length
if len(password) < 8:
return False
# Check complexity
if not any(c.isupper() for c in password):
return False
if not any(c.islower() for c in password):
return False
if not any(c.isdigit() for c in password):
return False
if not any(c in '!@#$%^&*()_-+={[}]|:;"\'<,>.?/~`' for c in password):
return False
# Additional checks if needed
return True

def show1():
hide_button = Button(RegistrationFrame, image=hide_image1, command=hide1,
relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
hide_button.place(x=452, y=426)
password.config(show='')

def hide1():

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 40


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

show_button = Button(RegistrationFrame, image=show_image1, command=show1,


relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
show_button.place(x=452, y=426)
password.config(show='*')

def show2():
hide_button2 = Button(RegistrationFrame, image=hide_image2, command=hide2,
relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
hide_button2.place(x=452, y=476)
confirm_password.config(show='')

def hide2():
show_button2 = Button(RegistrationFrame, image=show_image2, command=show2,
relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
show_button2.place(x=452, y=476)
confirm_password.config(show='*')
def show3():
hide_button = Button(loginFrame, image=hide_image3, command=hide3,
relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
hide_button.place(x=410, y=200)
vpassword.config(show='')

def hide3():
show_button = Button(loginFrame, image=show_image3, command=show3,
relief=FLAT,
activebackground="white"

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 41


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

, borderwidth=0, background="white", cursor="hand2")


show_button.place(x=410, y=200)
vpassword.config(show='*')

def AdminRegistration():
regId = StringVar()
name = StringVar()
age = StringVar()
aadhar = StringVar()
phone = StringVar()
gender = StringVar()

global
AdminFrame,show_image4,show_image5,hide_image4,hide_image5,apassword,aconfirm
_password

AdminFrame = Frame()
AdminFrame.place(x=0, y=0, width="500", height="600")
AdminFrame.configure(background="white")
label = Label(AdminFrame, text="Register for voting system ", font=(ARIAL, 20,
"bold"), bg="white", fg=HIGHLIGHT_TEXT)
label.place(x=60, y=50)

IdLabel = Label(AdminFrame, text="Register Id ", font=(ARIAL, 12, "normal"),


bg="white")
IdLabel.place(x=30, y=125)
IdInput = Entry(AdminFrame, font=(ARIAL, 12), textvariable=regId, border=0,
bg="#f0f0f0")
IdInput.place(x=250, y=125, width="200", height="25")

nameLabel = Label(AdminFrame, text="Full Name", font=(ARIAL, 12, "normal"),


bg="white")
nameLabel.place(x=30, y=175)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 42


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

nameInput = Entry(AdminFrame, font=(ARIAL, 12), textvariable=name, border=0,


bg="#f0f0f0")
nameInput.place(x=250, y=175, width="200", height="25")

ageLabel = Label(AdminFrame, text="Age", font=(ARIAL, 12, "normal"),


bg="white")
ageLabel.place(x=30, y=225)
ageInput = Entry(AdminFrame, font=(ARIAL, 12), textvariable=age, border=0,
bg="#f0f0f0")
ageInput.place(x=250, y=225, width="200", height="25")

aadharLabel = Label(AdminFrame, text="Aadhar Card Number", font=(ARIAL, 12,


"normal"), bg="white")
aadharLabel.place(x=30, y=275)
aadharInput = Entry(AdminFrame, font=(ARIAL, 12), textvariable=aadhar, border=0,
bg="#f0f0f0")
aadharInput.place(x=250, y=275, width="200", height="25")

phoneLabel = Label(AdminFrame, text="Mobile Number", font=(ARIAL, 12,


"normal"), bg="white")
phoneLabel.place(x=30, y=325)
phoneInput = Entry(AdminFrame, font=(ARIAL, 12), textvariable=phone, border=0,
bg="#f0f0f0")
phoneInput.place(x=250, y=325, width="200", height="25")

genderlabel = Label(AdminFrame, text="Gender", font=(ARIAL, 12, "normal"),


bg="white")
genderlabel.place(x=30, y=375)
genderInput=Combobox(root, values=["Male","Female"], font=("", 12, "normal"),
textvariable=gender)
genderInput.place(x=250, y=375, width="200", height="25")

apassword_label = Label(AdminFrame, text="Password",


font=(ARIAL, 13))

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 43


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

apassword_label.place(x=30, y=425)

apassword = Entry(AdminFrame, highlightthickness=0, relief=FLAT, bg="#f0f0f0",


font=(ARIAL, 12), show="*", insertbackground = '#6b6a69')
apassword.place(x=250, y=425, width=200)

# ========= show/hide password


================================================================
show_image4 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\show.png')

hide_image4 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\hide.png')

show_button4 = Button(AdminFrame, image=show_image4, command=show4,


relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
show_button4.place(x=460, y=425)

aconfirm_password_label = Label(AdminFrame, text="Password",


font=(ARIAL, 13))
aconfirm_password_label.place(x=30, y=475)

aconfirm_password = Entry(AdminFrame, highlightthickness=0, relief=FLAT,


bg="#f0f0f0",
font=(ARIAL, 12), show="*", insertbackground = '#6b6a69')
aconfirm_password.place(x=250, y=475, width=200)

# ========= show/hide password


================================================================
show_image5 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\show.png')

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 44


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

hide_image5 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\hide.png')

show_button5 = Button(AdminFrame, image=show_image5, command=show5,


relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
show_button5.place(x=460, y=475)

def Register():
if regId.get() == "" or name.get() == "" or age.get() == "" or aadhar.get() == "" or
phone.get() == "" or gender.get() == "" :
messagebox.showwarning('Voting System Message', 'All field is requird')
elif int(age.get())>60:
messagebox.showerror("Error","You are not eligible to register")
Home()
elif apassword.get() != aconfirm_password.get():
messagebox.showerror("Error", "Passwords do not match")
elif not is_valid_password(apassword.get()) or not
is_valid_password(aconfirm_password.get()):
messagebox.showerror("Error", "Passwords must meet the complexity
requirements")
else:
if len(aadhar.get()) == 12 and str(age.get()).isdigit() and len(phone.get()) == 10
and aadhar.get().isdigit() and phone.get().isdigit():
result = model.findByAadharinAdmin(aadhar.get())
result1 = model.findByRegId(regId.get())
model.add_Admin_password(regId.get(),apassword.get())
if((result == None) and (result1 == None)):
if(model.addAdmin(regId.get(), name.get(), age.get(), aadhar.get(),
phone.get(), gender.get())):
messagebox.showinfo('Voting System Message', 'Registered as Admin')
regId.set("")
name.set("")

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 45


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

age.set("")
aadhar.set("")
phone.set("")
gender.set("")
AdminLogin()

else:
messagebox.showwarning('Voting System Message', 'Try again later,
unable to register admin')

else:
messagebox.showerror('Voting System Message', 'Aadhar number is already
register')

else:
messagebox.showwarning('Voting System Message', 'Aadhar number must be
12 digit and Mobile number must be 10 digit')

Register_btn = Button(AdminFrame, text="Register", font=(ARIAL, 13, "bold"),


command=Register, border=0, bg=HIGHLIGHT_BG, fg="white")
Register_btn.place(x=175, y=525, width=150, height=50)
back_btn = Button(AdminFrame, text="< Back", font=(ARIAL, 10, "normal"),
command=AdminHome, border=0, bg="white", fg="grey")
back_btn.place(x=0, y=0, width=100, height=50)

def is_valid_password(password):
# Check length
if len(password) < 8:
return False
# Check complexity
if not any(c.isupper() for c in password):
return False

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 46


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

if not any(c.islower() for c in password):


return False
if not any(c.isdigit() for c in password):
return False
if not any(c in '!@#$%^&*()_-+={[}]|:;"\'<,>.?/~`' for c in password):
return False
# Additional checks if needed
return True

def show4():
hide_button4 = Button(AdminFrame, image=hide_image4, command=hide4,
relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
hide_button4.place(x=460, y=425)
apassword.config(show='')

def hide4():
show_button4 = Button(AdminFrame, image=show_image4, command=show4,
relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
show_button4.place(x=460, y=425)
apassword.config(show='*')

def show5():
hide_button5 = Button(AdminFrame, image=hide_image5, command=hide5,
relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
hide_button5.place(x=460, y=475)
aconfirm_password.config(show='')

def hide5():

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 47


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

show_button5 = Button(AdminFrame, image=show_image5, command=show5,


relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
show_button5.place(x=460, y=475)
aconfirm_password.config(show='*')

def VoterHome():
voterFrame = Frame()
voterFrame.place(x=0, y=0, width="900", height="500")
voterFrame.configure(background="white")
login_btn = Button(voterFrame, text="Login", font=(ARIAL, 13,
"bold"),command=voterLogin, relief=FLAT, border=0, bg=HIGHLIGHT_BG,
fg="white")
login_btn.place(x=150, y=150, width=150, height=50)
btn_border = LabelFrame(voterFrame, bd = 0, bg = HIGHLIGHT_BG)
btn_border.place(x=150, y=250, width=150, height=50)
reg_btn = Button(btn_border, text="Register", font=(ARIAL, 13, "bold"),
command=voterRegistration, relief=FLAT, border=0, bg="white", fg=HIGHLIGHT_BG)
reg_btn.place(x=1, y=1, width=148, height=48)
back_btn = Button(voterFrame, text="< Back", font=(ARIAL, 10, "normal"),
command=Home, border=0, bg="white", fg="grey")
back_btn.place(x=0, y=0, width=100, height=50)
label = Label(voterFrame, text="Your Vote,\nYour Voice",
font=(LUCIDA_CONSOLE, 30, "bold"), bg=HIGHLIGHT_BG, fg="white")
label.place(x=500, y=0, width=400, height=500)

def AdminHome():
adminFrame = Frame()
adminFrame.place(x=0, y=0, width="900", height="600")
adminFrame.configure(background="white")

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 48


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

login_btn = Button(adminFrame, text="Login", font=(ARIAL, 13,


"bold"),command=AdminLogin, relief=FLAT, border=0, bg=HIGHLIGHT_BG,
fg="white")
login_btn.place(x=150, y=150, width=150, height=50)
btn_border = LabelFrame(adminFrame, bd = 0, bg = HIGHLIGHT_BG)
btn_border.place(x=150, y=250, width=150, height=50)
reg_btn = Button(btn_border, text="Register", font=(ARIAL, 13, "bold"),
command=AdminRegistration, relief=FLAT, border=0, bg="white",
fg=HIGHLIGHT_BG)
reg_btn.place(x=1, y=1, width=148, height=48)
back_btn = Button(adminFrame, text="< Back", font=(ARIAL, 10, "normal"),
command=Home, border=0, bg="white", fg="grey")
back_btn.place(x=0, y=0, width=100, height=50)
label = Label(adminFrame, text="Our Vote,\nOur Voice",
font=(LUCIDA_CONSOLE, 30, "bold"), bg=HIGHLIGHT_BG, fg="white")
label.place(x=500, y=0, width=400, height=600)

def Home():
homeFrame = Frame()
homeFrame.place(x=0, y=0, width="900", height="500")
homeFrame.configure(background="white")
photo = Label(homeFrame, image = homeImg)
photo.place(x=300, y=80, width=600, height=350)
label = Label(homeFrame, text="Vote for the Future", font=(LUCIDA_CONSOLE,
30, "bold"), bg="white", fg=HIGHLIGHT_TEXT)
label.place(x=20, y=100)
voter_btn = Button(homeFrame, text="Voter ", font=(ARIAL, 13, "normal"),
command=VoterHome, relief=FLAT, border=0, bg=HIGHLIGHT_BG)
voter_btn.place(x=100, y=200, width=150, height=50)
btn_border = LabelFrame(homeFrame, bd = 0, bg = HIGHLIGHT_BG)
btn_border.place(x=100, y=300, width=150, height=50)
admin_btn = Button(btn_border, text="Admin", font=(ARIAL, 13, "normal"),
command=AdminHome, relief=FLAT, border=0, bg="white")
admin_btn.place(x=1, y=1, width=148, height=48)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 49


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

def AdminLogin():
global LoginFrame,vapassword,show_image6,hide_image6
regId = StringVar()
LoginFrame = Frame()
LoginFrame.place(x=0, y=0, width="500", height="600")
LoginFrame.configure(background="white")

label = Label(LoginFrame, text="Login to Voting System", font=(ARIAL, 20, "bold"),


bg="white", fg=HIGHLIGHT_TEXT)
label.place(x=100, y=50)

IdLable = Label(LoginFrame, text="Register Id", font=(ARIAL, 12, "normal"),


bg="white")
IdLable.place(x=100, y=150)
IdInput = Entry(LoginFrame, font=(ARIAL,12,"normal"), textvariable=regId,
border=0, bg="#f0f0f0")
IdInput.place(x=200, y=150, width="200", height="25")

vapassword_label = Label(LoginFrame, text="Password",


font=(ARIAL, 13))
vapassword_label.place(x=100, y=200)

vapassword = Entry(LoginFrame, highlightthickness=0, relief=FLAT, bg="#f0f0f0",


font=(ARIAL, 12), show="*", insertbackground = '#6b6a69')
vapassword.place(x=200, y=200, width=200)

# ========= show/hide password


================================================================
==
show_image6 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\show.png')

hide_image6 = ImageTk.PhotoImage \

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 50


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

(file='E:\PYTHON PROGRAMS\hide.png')

show_button6 = Button(LoginFrame, image=show_image6, command=show6,


relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
show_button6.place(x=410, y=200)

def Login():
if regId.get() == "":
messagebox.showwarning('Voting System Message', 'Field are required')

else:
result = model.findByRegId(regId.get())
result_password=model.check_admin_password(regId.get())
entered_password = vapassword.get()
if(result == None):
messagebox.showerror('Voting System Message', 'Wrong Credentials')
elif (result_password[0] != entered_password):
messagebox.showerror("Error","Wrong Password")
else:
AdminDashboard(regId.get())

regId.set("")

Login_btn = Button(LoginFrame, text="Login", font=(ARIAL, 13, "bold"),


command=Login, border=0, bg=HIGHLIGHT_BG, fg="white")
Login_btn.place(x=200, y=250, width=100, height=50)
back_btn = Button(LoginFrame, text="< Back", font=(ARIAL, 10, "normal"),
command=AdminHome, border=0, bg="white", fg="grey")
back_btn.place(x=0, y=0, width=100, height=50)

def show6():

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 51


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

hide_button6 = Button(LoginFrame, image=hide_image6, command=hide6,


relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
hide_button6.place(x=410, y=200)
vapassword.config(show='')

def hide6():
show_button6 = Button(LoginFrame, image=show_image6, command=show6,
relief=FLAT,
activebackground="white"
, borderwidth=0, background="white", cursor="hand2")
show_button6.place(x=410, y=200)
vapassword.config(show='*')

def AdminDashboard(regId):

dashboardFrame = Frame()
dashboardFrame.place(x=0, y=0, width=900, height=500)
dashboardFrame.configure(background="white")

admin_name = model.findByRegId(regId)

menu_bar = Frame(dashboardFrame)
menu_bar.place(x=0, y=0, width=249, height=500)
menu_bar.configure(background="#f0f0f0")

section = Frame(dashboardFrame)
section.place(x=249, y=0, width=651, height=500)
section.configure(background="grey")
votingResults()

admin = Frame(menu_bar)
admin.place(x=0, y=0, width=249, height=100)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 52


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

admin.configure(background=HIGHLIGHT_BG)

label = Label(admin, text=regId, font=(ARIAL, 15, "bold", UNDERLINE),


bg=HIGHLIGHT_BG, fg="white")
label.place(x=10, y=25)

label = Label(admin, text=admin_name[2], font=(LUCIDA_CONSOLE, 13,


"normal"), bg=HIGHLIGHT_BG, fg="white")
label.place(x=10, y=60)

update_btn = Button(menu_bar, text="Dashboard", font=(ARIAL, 13, "normal"),


command=votingResults, border=0, bg="white", fg="grey", anchor="w", padx=30)
update_btn.place(x=0, y=100, width=249, height=50)

delete_btn = Button(menu_bar, text="All Record", font=(ARIAL, 13, "normal"),


command=showAllRecord, border=0, bg="white", fg="grey", anchor="w", padx=30)
delete_btn.place(x=0, y=151, width=249, height=50)

search_btn = Button(menu_bar, text="Search User", font=(ARIAL, 13, "normal"),


command=searchUser, border=0, bg="white", fg="grey", anchor="w", padx=30)
search_btn.place(x=0, y=202, width=249, height=50)

data_btn = Button(menu_bar, text="Update User Records", font=(ARIAL, 13,


"normal"),command=updateUser, border=0, bg="white", fg="grey", anchor="w",
padx=30)
data_btn.place(x=0, y=253, width=249, height=50)

result_btn = Button(menu_bar, text="Delete User", font=(ARIAL, 13,


"normal"),command=deleteUser, border=0, bg="white", fg="grey", anchor="w",
padx=30)
result_btn.place(x=0, y=304, width=249, height=50)

logOut_btn = Button(menu_bar, text="Log Out", font=(ARIAL, 13, "normal"),


command=Home, border=0, bg="white", fg="grey", anchor="w", padx=30)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 53


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

logOut_btn.place(x=0, y=355, width=249, height=50)

space = Label(menu_bar, bg="white")


space.place(x=0, y=406, width=249, height=100)

def votingResults():

resultFrame = Frame()
resultFrame.place(x=250, y=0, width=650, height=500)
resultFrame.configure(background="white")

total=Label(resultFrame,text="Total
vote",font=(LUCIDA_CONSOLE,15,"bold"),bg="white",fg=HIGHLIGHT_TEXT)
total.place(x=150,y=50)
party1=Label(resultFrame,text="BJP",font=(LUCIDA_CONSOLE,15,"normal"),bg="
white",fg="grey")
party1.place(x=150,y=150)
party2=Label(resultFrame,text="TMC",font=(LUCIDA_CONSOLE,15,"normal"),bg=
"white",fg="grey")
party2.place(x=150,y=200)
party3=Label(resultFrame,text="Congress",font=(LUCIDA_CONSOLE,15,"normal"),
bg="white",fg="grey")
party3.place(x=150,y=250)
party4=Label(resultFrame,text="AAP",font=(LUCIDA_CONSOLE,15,"normal"),bg="
white",fg="grey")
party4.place(x=150,y=300)

result = model.getTotalCount()
t_user = model.getTotalUserCount()
totalCount=Label(resultFrame,text="{} / {}".format(result[0],
t_user[0]),font=("",15,"bold"), bg="white")
totalCount.place(x=400,y=50)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 54


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

result1 = model.getPartyCount("BJP")
count1=Label(resultFrame,text=result1, font=("",15,"bold"),bg="white")
count1.place(x=400,y=150)

result1 = model.getPartyCount("TMC")
count2=Label(resultFrame,text=result1, font=("",15,"bold"),bg="white")
count2.place(x=400,y=200)

result1 = model.getPartyCount("Congress")
count3=Label(resultFrame,text=result1, font=("",15,"bold"),bg="white")
count3.place(x=400,y=250)

result1 = model.getPartyCount("AAP")
count4=Label(resultFrame,text=result1, font=("",15,"bold"),bg="white")
count4.place(x=400,y=300)

def showAllRecord():
DataFrame = Frame()
DataFrame.place(x=250, y=0, width=650, height=600)
DataFrame.configure(background="white")
name=Label(DataFrame,text="Name",font=(LUCIDA_CONSOLE,13,"bold"),bg="whi
te",fg=HIGHLIGHT_TEXT)
name.place(x=20,y=20)
age=Label(DataFrame,text="Age",font=(LUCIDA_CONSOLE,13,"bold"),bg="white",
fg=HIGHLIGHT_TEXT)
age.place(x=150,y=20)
phone=Label(DataFrame,text="Phone
No.",font=(LUCIDA_CONSOLE,13,"bold"),bg="white",fg=HIGHLIGHT_TEXT)
phone.place(x=230,y=20)
gender=Label(DataFrame,text="Gender",font=(LUCIDA_CONSOLE,13,"bold"),bg="
white",fg=HIGHLIGHT_TEXT)
gender.place(x=370,y=20)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 55


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

address=Label(DataFrame,text="Locality",font=(LUCIDA_CONSOLE,13,"bold"),bg=
"white",fg=HIGHLIGHT_TEXT)
address.place(x=480,y=20)

result = model.getallVoters()

x=20
y=75
for r in result:
nameValue=Label(DataFrame,text=r[0],font=(ARIAL,12,"normal"),bg="white")
nameValue.place(x=x,y=y)
x+=140
ageValue=Label(DataFrame,text=r[1],font=(ARIAL,12,"normal"),bg="white")
ageValue.place(x=x,y=y)
x+=80
phoneValue=Label(DataFrame,text=r[2],font=(ARIAL,12,"normal"),bg="white")
phoneValue.place(x=x,y=y)
x+=130
genderValue=Label(DataFrame,text=r[3],font=(ARIAL,12,"normal"),bg="white")
genderValue.place(x=x,y=y)
x+=100
addressValue=Label(DataFrame,text=r[4],font=(ARIAL,12,"normal"),bg="white")
addressValue.place(x=x,y=y)
y+=50
x=20

def searchUser():
aadhar = StringVar()
SearchFrame = Frame()
SearchFrame.place(x=250, y=0, width=650, height=500)
SearchFrame.configure(background="white")
aadharLabel = Label(SearchFrame, text="Aadhar Card Number", font=("", 13,
"normal"), bg="white")

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 56


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

aadharLabel.place(x=50, y=55, height=30)


aadharInput = Entry(SearchFrame, textvariable=aadhar,font=("",12,"normal"),
bg="#f0f0f0", border=0)
aadharInput.place(x=230, y=55, width=170, height=30)
def search():
if aadhar.get() == "" or len(aadhar.get()) != 12 or not aadhar.get().isdigit():
messagebox.showwarning('Voting System Message', '🎱 Field is requird\n🎱
Aadhar number length must be 12 digit')

else:
user = model.getUserByAadhar(aadhar.get())
if(user == None):
messagebox.showinfo('Voting System Message', 'No such User')

else:
DataFrame = Frame(SearchFrame)
DataFrame.place(x=150, y=150, width=500, height=250)
DataFrame.configure(background="white")
name = Label(DataFrame, text="Name :", font=(ARIAL, 13, "bold"),
bg="white")
name.place(x=0, y=0, height=30)
nameValue = Label(DataFrame, text=user[0], font=(ARIAL, 12, "normal"),
bg="white")
nameValue.place(x=150, y=0, height=30)
age = Label(DataFrame, text="Age :", font=(ARIAL, 13, "bold"), bg="white")
age.place(x=0, y=50, height=30)
ageValue = Label(DataFrame, text=user[1], font=(ARIAL, 12, "normal"),
bg="white")
ageValue.place(x=150, y=50, height=30)
phone = Label(DataFrame, text="Mobile Number :", font=(ARIAL, 13,
"bold"), bg="white")
phone.place(x=0, y=100, height=30)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 57


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

phoneValue = Label(DataFrame, text=user[2], font=(ARIAL, 12, "normal"),


bg="white")
phoneValue.place(x=150, y=100, height=30)
gender = Label(DataFrame, text="Gender :", font=(ARIAL, 13, "bold"),
bg="white")
gender.place(x=0, y=150, height=30)
genderValue = Label(DataFrame, text=user[3], font=(ARIAL, 12, "normal"),
bg="white")
genderValue.place(x=150, y=150, height=30)
locality = Label(DataFrame, text="Locality :", font=(ARIAL, 13, "bold"),
bg="white")
locality.place(x=0, y=200, height=30)
localityValue = Label(DataFrame, text=user[4], font=(ARIAL, 12, "normal"),
bg="white")
localityValue.place(x=150, y=200, height=30)

search_btn = Button(SearchFrame, text="SEARCH", font=(ARIAL, 12, "bold"),


command=search, border=0, bg=HIGHLIGHT_BG, fg="white")
search_btn.place(x=450, y=50, width=150, height=40)

def updateUser():
aadhar = StringVar()
name = StringVar()
age = StringVar()
phone = StringVar()
gender = StringVar()
locality = StringVar()

UpdateFrame = Frame()
UpdateFrame.place(x=250, y=0, width=650, height=500)
UpdateFrame.configure(background="white")

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 58


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

aadharLabel = Label(UpdateFrame, text="Aadhar Card Number", font=("", 13,


"normal"), bg="white")
aadharLabel.place(x=50, y=55, height=30)
aadharInput = Entry(UpdateFrame, textvariable=aadhar,font=("",12,"normal"),
bg="#f0f0f0", border=0)
aadharInput.place(x=230, y=55, width=170, height=30)
def search():
if aadhar.get() == "" or len(aadhar.get()) != 12 or not aadhar.get().isdigit():
messagebox.showwarning('Voting System Message', '🎱 Field is requird\n🎱
Aadhar number length must be 12 digit')

else:
user = model.findByAadhar(aadhar.get())
if(user == None):
messagebox.showinfo('Voting System Message', 'No such User')

else:
DataFrame = Frame(UpdateFrame)
DataFrame.place(x=150, y=150, width=500, height=350)
DataFrame.configure(background="white")

name.set("")
age.set("")
phone.set("")
gender.set("")
locality.set("")

nameLabel = Label(DataFrame, text="Name ", font=(ARIAL, 13, "bold"),


bg="white")
nameLabel.place(x=0, y=0, height=30)
nameValue = Entry(DataFrame, font=(ARIAL, 12, "normal"),
textvariable=name, border=0, bg="#f0f0f0")
nameValue.insert(0, user[2])

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 59


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

nameValue.place(x=150, y=0, width=200, height=30)

ageLabel = Label(DataFrame, text="Age ", font=(ARIAL, 13, "bold"),


bg="white")
ageLabel.place(x=0, y=50, height=30)
ageValue = Entry(DataFrame, font=(ARIAL, 12, "normal"), textvariable=age,
border=0, bg="#f0f0f0")
ageValue.insert(0, user[3])
ageValue.place(x=150, y=50, width=200, height=30)

phoneLabel = Label(DataFrame, text="Mobile Number ", font=(ARIAL, 13,


"bold"), bg="white")
phoneLabel.place(x=0, y=100, height=30)
phoneValue = Entry(DataFrame, font=(ARIAL, 12, "normal"),
textvariable=phone, border=0, bg="#f0f0f0")
phoneValue.insert(0, user[5])
phoneValue.place(x=150, y=100, width=200, height=30)

genderLabel = Label(DataFrame, text="Gender ", font=(ARIAL, 13, "bold"),


bg="white")
genderLabel.place(x=0, y=150, height=30)
genderValue = Combobox(DataFrame, values=["Male","Female"],
font=(ARIAL, 12, "normal"), textvariable=gender)
genderValue.insert(0, user[6])
genderValue.place(x=150, y=150, width=200, height=30)

def update():
if name.get() == "" or age.get() == "" or phone.get() == "" or gender.get() ==
"" or len(phone.get()) != 10 or not phone.get().isdigit() :
messagebox.showwarning('Voting System Message', '🎱 Field is

requird\n🎱 Mobile number length must be 10 digit')

else:

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 60


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

if(model.updateUserByAadhar(name.get(), age.get(), phone.get(),


gender.get(), aadhar.get())):
messagebox.showinfo('Voting System Message', 'Updated
Successfully!!')
else:
messagebox.showwarning('Voting System Message', 'Try again later,
unable to update user')

name.set("")
age.set("")
phone.set("")
gender.set("")
aadhar.set("")
locality.set("")

update_btn = Button(DataFrame, text="Update", font=(ARIAL, 12, "normal"),


command=update, border=0, bg=HIGHLIGHT_BG, fg="white")
update_btn.place(x=150, y=200, width=100, height=40)

search_btn = Button(UpdateFrame, text="SEARCH", font=(ARIAL, 12, "bold"),


command=search, border=0, bg=HIGHLIGHT_BG, fg="white")
search_btn.place(x=450, y=50, width=150, height=40)

def deleteUser():
aadhar = StringVar()
DeleteFrame = Frame()
DeleteFrame.place(x=250, y=0, width=650, height=500)
DeleteFrame.configure(background="white")
aadharLabel = Label(DeleteFrame, text="Aadhar Number", font=(ARIAL, 13, "bold"),
bg="white")
aadharLabel.place(x=100, y=150, height=30)
aadharValue = Entry(DeleteFrame, textvariable=aadhar,font=(ARIAL,12,"normal"),
bg="#f0f0f0", border=0)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 61


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

aadharValue.place(x=275, y=150, width=250, height=30)


def delete():
if aadhar.get() == "" or len(aadhar.get()) != 12 or not aadhar.get().isdigit():
messagebox.showwarning('Voting System Message', '🎱 Field is requird\n🎱
Aadhar number length must be 12 digit')

else:
userResult = model.findByAadhar(aadhar.get())
if(userResult == None):
messagebox.showinfo('Voting System Message', 'No such User')

else:
if(model.deleteUserByAadhar(aadhar.get())):
messagebox.showinfo('Voting System Message', 'User Deleted')
else:
messagebox.showwarning('Voting System Message', 'Try again later, unable
to delete user')

aadhar.set("")

delete_btn = Button(DeleteFrame, text="Delete", font=(ARIAL, 13, "normal"),


command=delete, border=0, bg=HIGHLIGHT_BG, fg="white")
delete_btn.place(x=250, y=230, width=150, height=40)

def logout():
Home()

Home()
root.mainloop()

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 62


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

• Screenshots of the application.

Figure 8-1: Main Frame

Figure 8-2: Voter Dashboard

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 63


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

Figure 8-3: Voter Registration

Figure 8-4: Voter Login


Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 64
Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

Figure 8-5: Voting Frame

Figure 8-6: Admin Frame

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 65


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

Figure 8-7: Admin Registration

Figure 8-8: Admin Dashboard

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 66


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

Figure 8-9: Viewing All Records

Figure 8-10: Searching User by Aadhar

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 67


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

Figure 8-11: Updating User by Aadhar

Figure 8-12: Deleting User

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 68


Development of Online voting System Using Python Uni Reg.No.21014103 B.Tech (CSE)

Dept. Of Computer Science, SGGSWU, Fatehgarh Sahib 69

You might also like