Advertisement
mateog1998

Voting system

May 25th, 2015
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.20 KB | None | 0 0
  1. from Tkinter import *
  2. import tkMessageBox
  3. #def clicAndClose(event)
  4.  
  5. class app(object):
  6.     def __init__(self, parent):
  7.         self.availableCodes = [1,2, 3, 4, 5]
  8.    
  9.         top = self.top = Toplevel(parent)
  10.        
  11.         self.label1 = Label(top, text = "Ingrese su contrasena")
  12.         self.label1.pack()
  13.        
  14.         self.entry1 = Entry(top)
  15.         self.entry1.pack()
  16.        
  17.         self.button1 = Button(top, text = "Ingrese", command = self.ok)
  18.         self.button1.pack(pady= 5)
  19.    
  20.         self.button1val = 0
  21.         self.button2val = 0
  22.         self.button3val = 0
  23.         self.button4val = 0
  24.         self.button5val = 0
  25.         self.button6val = 0
  26.         self.button7val = 0
  27.         self.button8val = 0
  28.         self.button9val = 0
  29.         self.button10val = 0
  30.         self.button11val = 0
  31.         self.button12val = 0
  32.     def ok(self):
  33.         self.code = int(self.entry1.get())
  34.         self.voteWindow(self.code, self.availableCodes)
  35.         self.top.destroy()
  36.    
  37.     def voteWindow(self, code, listOfCodes):
  38.         if code in listOfCodes:
  39.             print "True"
  40.             self.optionsWindows()
  41.             listOfCodes.remove(code)
  42.         else:
  43.             print "False"
  44.        
  45.     def optionsWindows(self):
  46.         top = self.top = Toplevel(self.top)
  47.         topframe = Frame(top)
  48.         self.button1 = Button(topFrame, text = "Proyecto 1", command = self.close(self.button1val))#( self.button1val))
  49.         self.button1.pack(side = LEFT)
  50.  
  51.         self.button2 = Button(topFrame, text = "Proyecto 2", command =  self.close(self.button2val))#(options, self.button2val))
  52.         self.button2.pack(side = LEFT)
  53.  
  54.         self.button3 = Button(topFrame, text = "Proyecto 3", command =  self.close(self.button3val))#(options, self.button3val))
  55.         self.button3.pack(side = LEFT)
  56.  
  57.         self.button4 = Button(topFrame, text = "Proyecto 4", command =  self.close(self.button4val))#(options, self.button4val))
  58.         self.button4.pack(side = LEFT)
  59.  
  60.         self.button5 = Button(topFrame, text = "Proyecto 5", command =  self.close(self.button5val))#(options, self.button5val))
  61.         self.button5.pack(side = LEFT)
  62.  
  63.         self.button6 = Button(topFrame, text = "Proyecto 6", command =  self.close(self.button6val))#(options, self.button6val))
  64.         self.button6.pack(side = LEFT)
  65.  
  66.         self.button7 = Button(topFrame, text = "Proyecto 7", command = self.close(self.button7val))#(options, self.button7val))
  67.         self.button7.pack(side = LEFT)
  68.  
  69.         self.button8 = Button(topFrame, text = "Proyecto 8", command =  self.close(self.button8val))#(options, self.button8val))
  70.         self.button8.pack(side = LEFT)
  71.  
  72.         self.button9 = Button(topFrame, text = "Proyecto 9", command =  self.close(self.button9val))#(options, self.button9val))
  73.         self.button9.pack(side = LEFT)
  74.  
  75.         self.button10 = Button(topFrame, text = "Proyecto 10", command =  self.close(self.button10val))#(options, self.button10val))
  76.         self.button10.pack(side = LEFT)
  77.  
  78.         self.button11 = Button(topFrame, text = "Proyecto 11", command =  self.close(self.button11val))#(options, self.button11val))
  79.         self.button11.pack(side = LEFT)
  80.  
  81.         self.button12 = Button(topFrame, text = "Proyecto 12", command = self.close(self.button12val))#(options, self.button12val))
  82.         self.button12.pack(side = LEFT)
  83.  
  84.        
  85.     def close(self, variable):
  86.         variable +=1
  87.         self.top.destroy()
  88.        
  89.  
  90. def onClick():
  91.     run = app(root)
  92.     root.wait_window(run.top)
  93.        
  94.  
  95.  
  96. root = Tk()
  97.  
  98. root.configure(bg = "white")
  99. topFrame = Frame(root, bg = "white")
  100. topFrame.pack()
  101.  
  102. bottomFrame = Frame(root, bg = "white")
  103. bottomFrame.pack()
  104. label1 = Label(topFrame, text = 'Unidad Educativa Julio Verne', font=("Times",22), fg = 'forest green', bg = "white")
  105. label1.grid(row=0, column=0)
  106.  
  107. label2 = Label(topFrame, text = 'Sistema de Voto Electronico', font=("Times",20), fg = 'light sea green', bg = "white")
  108. label2.grid(row=1, column=0)
  109.  
  110. label3 = Label(topFrame, text = '2014-2015', font=("Times",22), fg = 'dark slate gray', bg = "white")
  111. label3.grid(row=2, column=0)
  112.  
  113. label4 = Label(bottomFrame, text = 'Proyecto 1', font=("Georgia",12), bg = "white")
  114. label4.grid(row=0, column=0)
  115.  
  116. label5 = Label(bottomFrame, text = 'Proyecto 2', font=("Georgia",12), bg = "white")
  117. label5.grid(row=1, column=0)
  118.  
  119. label6 = Label(bottomFrame, text = 'Proyecto 3', font=("Georgia",12), bg = "white")
  120. label6.grid(row=2, column=0)
  121.  
  122. label7 = Label(bottomFrame, text = 'Proyecto 4', font=("Georgia",12), bg = "white")
  123. label7.grid(row=3, column=0)
  124.  
  125. label8 = Label(bottomFrame, text = 'Proyecto 5', font=("Georgia",12), bg = "white")
  126. label8.grid(row=4, column=0)
  127.  
  128. label9 = Label(bottomFrame, text = 'Proyecto 6', font=("Georgia",12), bg = "white")
  129. label9.grid(row=5, column=0)
  130.  
  131. label10 = Label(bottomFrame, text = 'Proyecto 7', font=("Georgia",12), bg = "white")
  132. label10.grid(row=6, column=0)
  133.  
  134. label11 = Label(bottomFrame, text = 'Proyecto 8', font=("Georgia",12), bg = "white")
  135. label11.grid(row=7, column=0)
  136.  
  137. label12 = Label(bottomFrame, text = 'Proyecto 9', font=("Georgia",12), bg = "white")
  138. label12.grid(row=8, column=0)
  139.  
  140. label13 = Label(bottomFrame, text = 'Proyecto 10', font=("Georgia",12), bg = "white")
  141. label13.grid(row=9, column=0)
  142.  
  143. label14 = Label(bottomFrame, text = 'Proyecto 11', font=("Georgia",12), bg = "white")
  144. label14.grid(row=10, column=0)
  145.  
  146. label15 = Label(bottomFrame, text = 'Proyecto 12', font=("Georgia",12), bg = "white")
  147. label15.grid(row=11, column=0)
  148.  
  149.  
  150. mainButton = Button(root, text='Click aqui para votar', command=onClick)
  151. mainButton.pack()
  152.  
  153. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement