-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdmin.py
96 lines (72 loc) · 3.82 KB
/
Admin.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
87
88
89
90
91
92
93
94
95
96
import subprocess as sb_p
import tkinter as tk
from tkinter import font
import registerVoter as regV
import admFunc as adFunc
from tkinter import *
from registerVoter import *
from admFunc import *
# Modern color scheme and fonts
buttonColor = "#E1AFD1"
bgColor = "#FFE6E6"
fontColor = "#7469B6"
highlightColor = "#77cbb9" # Highlight color for hover effect
def AdminHome(root,frame1,frame3):
custom_font = font.Font(family="Lato", size=12, weight="bold")
root.title("Admin")
for widget in frame1.winfo_children():
widget.destroy()
Button(frame3, text="Admin", command = lambda: AdminHome(root, frame1, frame3), fg=fontColor, bg=buttonColor, font=custom_font).grid(row = 1, column = 0)
frame3.pack(side=TOP)
Label(frame1, text="Admin", fg=fontColor, bg=bgColor, font=('Helvetica', 25, 'bold')).grid(row = 0, column = 1)
Label(frame1, text="", fg=fontColor, bg=bgColor).grid(row = 1,column = 0)
#Admin Login
runServer = Button(frame1, text="Run Server", fg=fontColor, bg=buttonColor, font=custom_font, width=15, command = lambda: sb_p.call('start python Server.py', shell=True))
#Voter Login
registerVoter = Button(frame1, text="Register Voter", fg=fontColor, bg=buttonColor, font=custom_font, width=15, command = lambda: regV.Register(root, frame1))
#Show Votes
showVotes = Button(frame1, text="Show Votes", fg=fontColor, bg=buttonColor, font=custom_font, width=15, command = lambda: adFunc.showVotes(root, frame1))
#Reset Data
reset = Button(frame1, text="Reset Vote", fg=fontColor, bg=buttonColor, font=custom_font, width=15, command = lambda: adFunc.resetAll(root, frame1))
Label(frame1, text="", fg=fontColor, bg=bgColor).grid(row = 2,column = 0)
Label(frame1, text="", fg=fontColor, bg=bgColor).grid(row = 4,column = 0)
Label(frame1, text="", fg=fontColor, bg=bgColor).grid(row = 6,column = 0)
Label(frame1, text="", fg=fontColor, bg=bgColor).grid(row = 8,column = 0)
runServer.grid(row = 3, column = 1, columnspan = 2)
registerVoter.grid(row = 5, column = 1, columnspan = 2)
showVotes.grid(row = 7, column = 1, columnspan = 2)
reset.grid(row = 9, column = 1, columnspan = 2)
frame1.pack()
root.mainloop()
def log_admin(root,frame1,admin_ID,password):
if(admin_ID=="Admin" and password=="admin"):
frame3 = root.winfo_children()[1]
AdminHome(root, frame1, frame3)
else:
msg = Message(frame1, text="Either ID or Password is Incorrect", width=500, fg=fontColor, bg=bgColor)
msg.grid(row = 6, column = 0, columnspan = 5)
def AdmLogin(root,frame1):
root.title("Admin Login")
for widget in frame1.winfo_children():
widget.destroy()
Label(frame1, text="Admin Login", font=('Helvetica', 18, 'bold'), fg=fontColor, bg=bgColor).grid(row = 0, column = 2, rowspan=1)
Label(frame1, text="", fg=fontColor, bg=bgColor).grid(row = 1,column = 0)
Label(frame1, text="Admin ID: ", fg=fontColor, bg=bgColor, anchor="e", justify=LEFT).grid(row = 2,column = 0)
Label(frame1, text="Password: ", fg=fontColor, bg=bgColor, anchor="e", justify=LEFT).grid(row = 3,column = 0)
admin_ID = tk.StringVar()
password = tk.StringVar()
e1 = Entry(frame1, textvariable = admin_ID)
e1.grid(row = 2,column = 2)
e2 = Entry(frame1, textvariable = password, show = '*')
e2.grid(row = 3,column = 2)
sub = Button(frame1, text="Login", width=10, bg=buttonColor, fg=fontColor, command = lambda: log_admin(root, frame1, admin_ID.get(), password.get()))
Label(frame1, text="", fg=fontColor, bg=bgColor).grid(row = 4,column = 0)
sub.grid(row = 5, column = 3, columnspan = 2)
frame1.pack()
root.mainloop()
# if __name__ == "__main__":
# root = Tk()
# root.geometry('500x500')
# frame1 = Frame(root)
# frame3 = Frame(root)
# AdminHome(root,frame1,frame3)