GUI for the EVM machine

Files at this revision

API Documentation at this revision

Comitter:
priyanshu_varshney
Date:
Thu Nov 22 22:32:42 2018 +0000
Commit message:
GUI for the EVM

Changed in this revision

GUI.py Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 96d6bd6c646f GUI.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GUI.py	Thu Nov 22 22:32:42 2018 +0000
@@ -0,0 +1,250 @@
+from tkinter import *
+import tkinter.messagebox as box
+import pandas as pd
+import os
+import serial
+import array
+import pyttsx3
+
+global name
+global gender
+global age
+global house
+party = []
+count = []
+
+
+class Auth:
+    def __init__(self,master):
+        self.t = 2
+        self.master = master
+        window = self.master
+        window.title('Countries Generation')
+
+        self.frame = Frame(window)
+
+        self.Label1 = Label(window,text = 'Username:')
+        self.Label1.pack(padx=15,pady= 5)
+
+        self.entry1 = Entry(window,bd =5)
+        self.entry1.pack(padx=15, pady=5)
+        self.Label2 = Label(window,text = 'Password: ')
+        self.Label2.pack(padx = 15,pady=6)
+
+        self.entry2 = Entry(window, bd=5,show="*")
+        self.entry2.pack(padx = 15,pady=7)
+        # widget = Entry(parent, show="*", width=15)
+
+        self.btn = Button(self.frame, text = 'Check Login',command = self.dialog)
+        
+        self.btn.pack(side = RIGHT , padx =5)
+        self.frame.pack(padx=100,pady = 19)
+    def dialog(self):
+        username=self.entry1.get()
+        password = self.entry2.get()
+        if(username == 'khoury' and password=='khoury'):
+            box.showinfo('info','Correct')
+            self.t=1
+
+        else:
+            box.showinfo('info','Wrong-'+str(self.t))
+        if(self.t == 1):
+            self.t=2
+            root2 = Toplevel(self.master)
+            myGui = Main(root2)
+            # root2 = Toplevel(self.master)
+            # myGui = Proceed(root2)
+            # self.master.destroy()
+
+class Main():
+    def __init__(self,master):
+        self.master =master
+        window = self.master
+        self.master.title('Main Window')
+        self.frame = Frame(window)
+        self.btn = Button(self.frame, text = 'Credentials Checking',command = self.open_cred)
+        self.btn.pack(side = RIGHT , padx =5)
+        self.btn2 = Button(self.frame, text = 'Results',command = self.results)
+        self.btn2.pack(side = LEFT , padx =5)
+        
+        self.frame.pack(padx=100,pady = 19)
+    def open_cred(self):
+        root3 = Toplevel(self.master)
+        myGui2 = Proceed(root3)
+    def results(self):
+        root3 = Toplevel(self.master)
+        myGui2 = Results(root3)
+    
+            
+class Proceed:
+    def __init__(self,master):
+        
+        self.master = master
+        window = self.master
+        self.master.title('Credentials Check')
+        self.frame = Frame(window)
+        self.Label1 = Label(window,text = 'Votercard ID:')
+        self.Label1.pack(padx=15,pady= 5)
+
+        self.entry1 = Entry(window,bd =5)
+        self.entry1.pack(padx=15, pady=5)
+
+        self.btn = Button(self.frame, text = 'Check Credentials',command = self.checker)
+        self.btn.pack(side = RIGHT , padx =5)
+        self.frame.pack(padx=100,pady = 19)
+
+    def checker(self):
+        voteID = self.entry1.get()
+        df_out = pd.read_excel('/home/conan/Desktop/EVM/data.xlsx')
+        df_out.set_index("voter_id", inplace=True)
+        df_out.loc[voteID]
+        global name
+        global gender
+        global age
+        global house
+        name=df_out.loc[voteID,['name_e']].tolist()
+        gender=df_out.loc[voteID,['gender']].tolist()
+        age=df_out.loc[voteID,['age']].tolist()
+        house=df_out.loc[voteID,['house_no']].tolist()
+        
+        root3 = Toplevel(self.master)
+
+        myGui2 = Proceed2(root3)
+# # ZME0069054
+class Proceed2:
+    def __init__(self,master):
+
+        self.master = master
+        window = self.master
+        self.master.title('Voter Information From Database')
+        self.frame = Frame(window)
+        self.Label1 = Label(window,text = 'Voter Name:')
+        self.Label1.pack(padx=15,pady= 5)
+        self.Label2 = Label(window,text = name)
+        self.Label2.pack(padx=30,pady= 5)
+        self.Label3 = Label(window,text = 'Voter Age:')
+        self.Label3.pack(padx=15,pady= 5)
+        self.Label4 = Label(window,text = age)
+        self.Label4.pack(padx=30,pady= 5)
+        self.Label5 = Label(window,text = 'Voter Gender:')
+        self.Label5.pack(padx=15,pady= 5)
+        self.Label6 = Label(window,text = gender)
+        self.Label6.pack(padx=30,pady= 5)
+        self.Label7 = Label(window,text = 'Voter HouseAdd:')
+        self.Label7.pack(padx=15,pady= 5)
+        self.Label8 = Label(window,text = house)
+        self.Label8.pack(padx=30,pady= 5)
+        self.btn = Button(self.frame, text = 'Okay',command = self.send_red)
+        self.btn.pack(side = RIGHT , padx =5)
+        self.frame.pack(padx=100,pady = 19)
+
+    def send_red(self):
+        self.master.destroy()
+
+class Results:
+    def __init__(self,master):
+
+        self.master= master
+        window = self.master
+        self.master.title('Results')
+        self.frame = Frame(window)
+        global party
+        global count
+        party = ['a','b','c','d','e','f','g']
+        count = [1,2,3,4,5,6,7]
+        self.btn = Button(self.frame, text = 'Statistics',command = self.stat)
+        self.btn.pack(side = RIGHT , padx =5)
+        self.btn2 = Button(self.frame, text = 'Winner',command = self.fetch_data)
+        self.btn2.pack(side = RIGHT , padx =5)
+        self.btn2 = Button(self.frame, text = 'Graph')
+        self.btn2.pack(side = RIGHT , padx =5)
+        self.frame.pack(padx=100,pady = 19)
+
+
+    def fetch_data(self):
+        root4 = Toplevel(self.master)
+        myGui = Proceed4(root4)
+        
+    def stat(self):
+        root4 = Toplevel(self.master)
+        myGui = Proceed3(root4)
+
+class Proceed4:
+    def __init__(self,master):
+        self.master = master
+        window = self.master
+        self.master.title('Winner')
+        self.frame = Frame(window)
+        idx = count.index(max(count))
+        engine = pyttsx3.init();
+        rate =10
+        newVolume = 0.0001
+        def say(text):
+            engine.say(text)
+            engine.setProperty('voice', 0)
+            engine.setProperty('rate', rate)
+            engine.setProperty('volume', newVolume)
+            engine.runAndWait()
+
+        say("CONGRATULATIONS! The winner party is " + party[idx])
+
+        self.Label1 = Label(window,text = "Winner is : " + str(party[idx]))
+        self.Label1.pack(padx=15,pady= 5)
+        self.frame.pack(padx=100,pady = 19)
+
+
+
+class Proceed3:
+    def __init__(self,master):
+
+        self.master = master
+        window = self.master
+        self.master.title('Statistics')
+        self.frame = Frame(window)
+        self.Label1 = Label(window,text = party[0]+" : "+str(count[0]))
+        self.Label1.pack(padx=15,pady= 5)
+        # self.Label2 = Label(window,text = count[0])
+        # self.Label2.pack(padx=15,pady= 5)
+        self.Label3 = Label(window,text = party[1]+" : "+str(count[1]))
+        self.Label3.pack(padx=15,pady= 5)
+        # self.Label4 = Label(window,text =count[1] )
+        # self.Label4.pack(padx=30,pady= 5)
+        self.Label5 = Label(window,text = party[2]+" : "+str(count[2]))
+        self.Label5.pack(padx=15,pady= 5)
+        # self.Label6 = Label(window,text = count[2])
+        # self.Label6.pack(padx=30,pady= 5)
+        self.Label7 = Label(window,text = party[3]+" : "+str(count[3]))
+        self.Label7.pack(padx=15,pady= 5)
+        # self.Label8 = Label(window,text = count[3])
+        # self.Label8.pack(padx=30,pady= 5)
+
+        self.Label7 = Label(window,text = party[4]+" : "+str(count[4]))
+        self.Label7.pack(padx=15,pady= 5)
+        # self.Label8 = Label(window,text = count[4])
+        # self.Label8.pack(padx=30,pady= 5)
+
+        self.Label7 = Label(window,text = party[5]+" : "+str(count[5]))
+        self.Label7.pack(padx=15,pady= 5)
+        # self.Label8 = Label(window,text = count[5])
+        # self.Label8.pack(padx=30,pady= 5)
+
+        self.Label7 = Label(window,text = party[6]+" : "+str(count[6]))
+        self.Label7.pack(padx=15,pady= 5)
+        # self.Label8 = Label(window,text = count[6])
+        # self.Label8.pack(padx=30,pady= 5)
+
+        self.btn = Button(self.frame, text = 'Okay',command = self.send_red)
+        self.btn.pack(side = RIGHT , padx =5)
+        self.frame.pack(padx=100,pady = 19)
+
+    def send_red(self):
+        self.master.destroy()
+    
+
+def main():
+    root =Tk()
+    auth = Auth(root)
+    root.mainloop()
+
+if __name__ == '__main__':
+    main()
\ No newline at end of file