-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
232 lines (178 loc) · 6.51 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import kivy
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.label import Label
from kivy.uix.checkbox import CheckBox
from kivy.uix.gridlayout import GridLayout
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
#from kivy.uix.image import Image
Window.clearcolor=(20/255.0,20/255.0,20/255.0,1)
class Main(GridLayout):
def __init__(self,**kwargs):
super().__init__(**kwargs)
self.cols=1
#self.add_widget(Label())
self.title=Label(text='ONEVA',color=(0,1,0,1),pos=(350,500),font_size=35)
self.add_widget(self.title)
self.add_widget(Label())
self.add_widget(Label(text='ONLINE NATIONAL ELECTION VOTING APP',color=(0,1,0,1),font_size=20))
self.add_widget(Label())
self.start_button=Button(text='START',background_color=(0,500/255.0,0,1))
self.start_button.bind(on_press=self.goingto_start)
self.add_widget(self.start_button)
self.about_button=Button(text='ABOUT AND HOW TO USE',background_color=(0,500/255.0,0,1))
self.about_button.bind(on_press=self.goingto_about)
self.add_widget(self.about_button)
def goingto_start(self, instance):
oneva.sm.current='start'
def goingto_about(self, instance):
oneva.sm.current='about'
class Start(GridLayout):
def __init__(self,**kwargs):
super().__init__(**kwargs)
self.cols=2
self.add_widget(Label(text='ENTER THE ',color=(0,1,0,1)))
self.add_widget(Label(text='REQUIREMENTS BELOW',color=(0,1,0,1)))
#Full Name
self.add_widget(Label(text='Enter your full name: ',color=(0,1,0,1)))
self.full_name=TextInput(multiline=False)
self.add_widget(self.full_name)
#NIDA card number
self.add_widget(Label(text='NIDA card number: ',color=(0,1,0,1)))
self.nida_no=TextInput(multiline=False)
self.add_widget(self.nida_no)
#Year of birth
self.add_widget(Label(text='Enter year of birth: ',color=(0,1,0,1)))
self.yr=TextInput(multiline=False)
self.add_widget(self.yr)
#self.add_widget(Label())
self.back=Button(text='GO BACK',background_color=(0,500/255.0,0,1))
self.back.bind(on_press=self.gb)
self.add_widget(self.back)
self.submit=Button(text='SUBMIT',background_color=(0,500/255.0,0,1))
self.submit.bind(on_press=self.submitting)
self.add_widget(self.submit)
def submitting(self, instance):
name=self.full_name.text
nida=self.nida_no.text
year=self.yr.text
if name=='twm' and nida=='1234' and year=='2005':
#self.add_widget(Label(text='IT WORKED GO AND VOTE',color=(0,1,0,1)))
oneva.sm.current='voting'
elif name=='Ignace Amani Mchallo' and nida=='12345' and year=='1956':
oneva.sm.current='voting'
else:
#oneva.sm.current='main'
oneva.sm.current='voting'
def gb(self, instance):
oneva.sm.current='main'
class Voting(GridLayout):
def __init__(self,**kwargs):
super().__init__(**kwargs)
self.cols=2
self.add_widget(Label(text="CHOOSE WHOM YOU WANT",color=(0,1,0,1)))
self.add_widget(Label(text="TO VOTE FOR BELOW",color=(0,1,0,1)))
self.add_widget(Label())
self.add_widget(Label())
#self.add_widget(Label())
#self.add_widget(Label())
self.add_widget(Label(text='MAGUFULI',color=(0,1,0,1),font_size=20))
self.add_widget(Label(text='LISSU',color=(0,1,0,1),font_size=20))
#self.add_widget(CheckBox(color=(0,1,0,1)))
#self.add_widget(CheckBox(color=(0,1,0,1)))
self.f=CheckBox(color=(0,1,0,1))
self.add_widget(self.f)
self.f1=CheckBox(color=(0,1,0,1))
#self.f1.bind(on_press=self.check)
self.add_widget(self.f1)
self.magufuli=Button(text='VOTE MAGUFULI',background_color=(0,500/255.0,0,1))
#self.add_widget(self.magufuli)
self.lissu=Button(text='VOTE LISSU',background_color=(0,500/255.0,0,1))
#self.add_widget(self.lissu)
self.back=Button(text='GO BACK',background_color=(0,500/255.0,0,1))
self.back.bind(on_press=self.gh)
self.add_widget(self.back)
self.fisrst=CheckBox()
#self.add_widget(self.fisrst)
self.nothing=Button(text='SUBMIT',background_color=(0,500/255.0,0,1))
self.nothing.bind(on_press=self.check)
self.add_widget(self.nothing)
def check(self, instance):
#oneva.sm.current='main'
#self.add_widget(Label(text='TOO BAD! HE LOST',color=(1,0,0,1)))
if self.f.active:
self.add_widget(Label(text='WON',color=(0,1,0,1)))
ans='MAGUFULI'
fmsg=f'Thank you for using ONEVA to choose {ans}'
oneva.finish.update(fmsg)
oneva.sm.current='finish'
elif self.f1.active:
self.add_widget(Label(text='LOST',color=(1,0,0,1)))
ans='LISSU'
fmsg=f'Thank you for using ONEVA to choose {ans}'
oneva.finish.update(fmsg)
oneva.sm.current='finish'
def gh(self, instance):
oneva.sm.current='main'
#self.add_widget(Label())
#self.add_widget(Label())
class Finish(GridLayout):
def __init__(self,**kwargs):
super().__init__(**kwargs)
self.cols=1
self.message=Label(halign='center',font_size=27,color=(0,1,0,1))
self.add_widget(self.message)
self.add_widget(Label())
self.add_widget(Label())
self.add_widget(Label())
self.exit_button=Button(text='EXIT',background_color=(0,500/255.0,0,1))
self.exit_button.bind(on_press=self.ex)
self.add_widget(self.exit_button)
def update(self,message):
self.message.text=message
def ex(self, instance):
exit()
class About(GridLayout):
def __init__(self,**kwargs):
super().__init__(**kwargs)
self.cols=1
with open('about.txt','r') as f:
about_info=f.read()
self.info=Label(text=about_info,color=(0,1,0,1))
self.add_widget(self.info)
self.add_widget(Label())
#self.add_widget(Label())
self.g=Button(text='GO BACK',background_color=(0,500/255.0,0,1))
self.g.bind(on_press=self.gh)
self.add_widget(self.g)
def gh(self, instance):
oneva.sm.current='main'
class ONEVAApp(App):
def build(self):
self.sm=ScreenManager()
self.main=Main()
screen=Screen(name='main')
screen.add_widget(self.main)
self.sm.add_widget(screen)
self.start=Start()
screen=Screen(name='start')
screen.add_widget(self.start)
self.sm.add_widget(screen)
self.voting=Voting()
screen=Screen(name='voting')
screen.add_widget(self.voting)
self.sm.add_widget(screen)
self.about=About()
screen=Screen(name='about')
screen.add_widget(self.about)
self.sm.add_widget(screen)
self.finish=Finish()
screen=Screen(name='finish')
screen.add_widget(self.finish)
self.sm.add_widget(screen)
return self.sm
if __name__=='__main__':
oneva=ONEVAApp()
oneva.run()