-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
86 lines (64 loc) · 2.87 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import mysql.connector
import tkinter as tk
from PIL import Image, ImageTk
from tkinter import messagebox
def verify_aadhar():
aadhar_number = entry.get()
try:
# Establish a connection to the MySQL server
connection = mysql.connector.connect(
host='localhost',
user='root',
password='Shikhar@12',
database='voters'
)
# Create a cursor object to execute SQL queries
cursor = connection.cursor()
# Check if the Aadhar number exists in the voters1 table
query = "SELECT * FROM voters1 WHERE aadhar = %s"
cursor.execute(query, (aadhar_number,))
voter_result = cursor.fetchone()
if voter_result:
# Check if the Aadhar number exists in the votes table
query = "SELECT * FROM votes WHERE aadhar = %s"
cursor.execute(query, (aadhar_number,))
vote_result = cursor.fetchone()
if vote_result:
messagebox.showinfo("Vote Status", "Vote already casted.")
else:
messagebox.showinfo("Vote Status", "Voter ID exists. Calling finger.py module...")
import finger
# Call the necessary function from the finger.py module here
else:
messagebox.showinfo("Vote Status", "Voter ID does not exist.")
# Close the cursor and connection
cursor.close()
connection.close()
except mysql.connector.Error as error:
messagebox.showerror("MySQL Error", f"Error connecting to MySQL: {error}")
# Create a Tkinter window
window = tk.Tk()
window.title("Voting Machine")
window.geometry("800x800")
background_image = Image.open("C:\\Users\\shikh\\OneDrive\\Desktop\\hiluuu\\logo\\background.png")
background_photo = ImageTk.PhotoImage(background_image)
# Create a label to hold the background image
background_label = tk.Label(window, image=background_photo)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
# Create small icons on the top right corner
icon1 = tk.PhotoImage(file="C:\\Users\\shikh\\OneDrive\\Desktop\\hiluuu\\logo\\eci_logo.png").subsample(5, 5)
icon2 = tk.PhotoImage(file="C:\\Users\\shikh\\OneDrive\\Desktop\\hiluuu\\logo\\Adhaar-Logo.png").subsample(19, 19)
icon_label1 = tk.Label(window, image=icon1)
icon_label1.place(x=100, y=10)
icon_label2 = tk.Label(window, image=icon2)
icon_label2.place(x=180, y=10)
# Create a label and an entry field for Aadhar number
label = tk.Label(window, text="Enter Aadhar Card Number:", font=("Arial", 12))
label.place(relx=0.5, rely=0.3, anchor="center")
entry = tk.Entry(window, font=("Arial", 12))
entry.place(relx=0.5, rely=0.4, anchor="center")
# Create a button to verify Aadhar number
button = tk.Button(window, text="Verify", command=verify_aadhar, font=("Arial", 12))
button.place(relx=0.5, rely=0.5, anchor="center")
# Start the Tkinter event loop
window.mainloop()