Professional Documents
Culture Documents
Online Voting System (Harsh) - 1
Online Voting System (Harsh) - 1
Project Report
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.
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
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.
• 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
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.
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:
- 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:
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.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.
Table below shows a comparison between our proposed system tool and other voting system
tools.
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.
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)
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.
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.
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.
3.2.2 Flowchart
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.
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
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
➢ Image Processing
➢ Machine Learning
➢ Mobile Apps
➢ Multimedia
➢ Computer Networking
➢ Scientific Computing
➢ System Administration
➢ Test Frameworks
➢ Text Processing
➢ Web Frameworks
➢ Web Scraping
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:
➢ 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
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.
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.
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.
1. Registration:
- The system should validate the input data and ensure that the email address is unique.
2. Login:
3. Submit Vote:
1. Admin Registration:
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:
- 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.
- 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.
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:
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.
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.
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.
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.
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.
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
Appendices
• Python code for Application.
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")
hide_image3 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\hide.png')
def Login():
if(voterId.get() == ""):
messagebox.showwarning('Voting System Message', 'Field are required')
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("")
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])
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()
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")
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")
font=(ARIAL, 13))
password_label1.place(x=30, y=425)
hide_image1 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\hide.png')
hide_image2 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\hide.png')
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())
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')
def is_valid_username(username):
# Check length
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():
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"
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)
apassword_label.place(x=30, y=425)
hide_image4 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\hide.png')
hide_image5 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\hide.png')
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("")
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')
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
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():
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")
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)
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")
hide_image6 = ImageTk.PhotoImage \
(file='E:\PYTHON PROGRAMS\hide.png')
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("")
def show6():
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)
admin.configure(background=HIGHLIGHT_BG)
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)
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)
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")
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)
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")
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("")
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
else:
name.set("")
age.set("")
phone.set("")
gender.set("")
aadhar.set("")
locality.set("")
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)
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("")
def logout():
Home()
Home()
root.mainloop()