-
Notifications
You must be signed in to change notification settings - Fork 0
/
Registration Program.py
219 lines (158 loc) · 6.46 KB
/
Registration Program.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
from operator import index
import PySimpleGUI as sg
import ezsheets
def isExist(studentID, sheet):
return studentID in sheet.getColumn(1)
def isCheckIn(studentID, sheet):
return sheet.getColumn(5)[sheet.getColumn(1).index(studentID)] == "TRUE"
def getData(studentID, sheet, col):
return sheet.getColumn(col)[sheet.getColumn(1).index(studentID)]
def PopUpWindow(title, txt):
sz = 20
if txt == "Success!":
sz = 30
popUpElements = [
[sg.Text(txt, font = ("Futura", sz))],
[sg.Button("Back", font = ("Futura", 18), key = "-Back-")]
]
popUpLayout = [
[sg.VPush()],
[sg.Push(), sg.Column(popUpElements, element_justification='c'), sg.Push()],
[sg.VPush()]
]
window = sg.Window(title, popUpLayout, modal = True, size = (400, 250))
while True:
event, values = window.read(timeout = 1250)
if event in ("__TIMEOUT__"):
break
if event == sg.WIN_CLOSED or event == "-Back-":
break
window.close()
def checkIn(studentID, sheet):
sheet["E" + str(sheet.getColumn(1).index(studentID)+1)] = "TRUE"
PopUpWindow("Registration System", "Success!")
def BaanWindow(sheet):
pass
def DisplayWindow(studentID, sheet, isStaff):
if isStaff:
displayElements = [
[sg.VPush()],
[sg.Text("Student ID: " + studentID, font = ("Futura", 30))],
[sg.Text("Name: " + getData(studentID, sheet, 2), font = ("Futura", 30))],
[sg.Text("Nickname: " + getData(studentID, sheet, 3), font = ("Futura", 30))],
[sg.Text("Position: " + getData(studentID, sheet, 4), font = ("Futura", 30))],
[sg.Text("Remark: " + getData(studentID, sheet, 6), font = ("Futura", 30))],
[sg.VPush()]
]
else:
displayElements = [
[sg.VPush()],
[sg.Text("No. : " + getData(studentID, sheet, 2), font = ("Futura", 30))],
[sg.Text("Student ID: " + studentID, font = ("Futura", 30))],
[sg.Text("Name: " + getData(studentID, sheet, 3), font = ("Futura", 30))],
[sg.Text("Nickname: " + getData(studentID, sheet, 4), font = ("Futura", 30))],
[sg.Text("T-Shirt Size: " + getData(studentID, sheet, 6), font = ("Futura", 30))],
[sg.Text("Remark: " + getData(studentID, sheet, 9), font = ("Futura", 30))],
[sg.VPush()]
]
displayLayout = [
[sg.VPush()],
[sg.Push(), sg.Column(displayElements, element_justification='l'), sg.Push()],
[sg.Push(), sg.Column([[sg.Button("Check-in", font = ("Futura", 30), size = (10, 1), key = "-CheckIn-", focus = True)]], element_justification = 'c'), sg.Push()],
[sg.VPush()]
]
window = sg.Window("Registration System", displayLayout, size = (800, 600))
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
if event == "-CheckIn-":
checkIn(studentID, sheet)
break
window.close()
def SearchWindow(sheet, isStaff = True):
searchElements = [
[sg.Text("Enter Student ID: ", font = ("Futura", 30)), sg.InputText(size = (10, 1), font = ("Futura", 30), do_not_clear = False, key = "-Input-")],
[sg.VPush()],
[sg.Button("Continue", font = ("Futura", 30), size = (10, 1), key = "-Continue-")]
]
searchLayout = [
[sg.VPush()],
[sg.Push(), sg.Column(searchElements, element_justification='c'), sg.Push()],
[sg.VPush()]
]
window = sg.Window("Registration System", searchLayout, size = (800, 600), finalize = True)
window["-Input-"].bind("<Return>", "_Enter")
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED:
break
if event == "-Continue-" or event == "-Input-" + "_Enter":
studentID = values["-Input-"]
if len(studentID) == 10 and isExist(studentID, sheet):
if isCheckIn(studentID, sheet):
PopUpWindow("Registration System", "You have already checked in")
else:
window.hide()
DisplayWindow(studentID, sheet, isStaff)
window.un_hide()
else:
PopUpWindow("Registration System", "Your student ID does not exist")
window.close()
def FreshmenWindow(sheet):
freshmenElements = [
[sg.Text("Please select operation", font = ("Futura", 30))],
[sg.Text(" ", font = ("Futura", 30))],
[sg.Button("Check In", font = ("Futura", 30), size = (20, 1), key = "-CHECKIN-")],
[sg.Button("Baan", font = ("Futura", 30), size = (20, 1), key = "-BAAN-")]
]
freshmenLayout = [
[sg.VPush()],
[sg.Push(), sg.Column(freshmenElements, element_justification = "c"), sg.Push()],
[sg.VPush()]
]
window = sg.Window("Registration System", freshmenLayout, size = (800, 600))
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
if event == "-CHECKIN-":
window.hide()
SearchWindow(sheet, False)
window.un_hide()
if event == "-BAAN-":
window.hide()
BaanWindow(sheet)
window.un_hide()
window.close()
def main():
sg.theme("LightBrown")
sheetID = "1vFFBYLlZ01aLi0TNHqbWZKWJ6QIGHDp9x9Beca03CMI"
sheet = ezsheets.Spreadsheet(sheetID)
mainElements = [
[sg.Text("Please select type of participant", font = ("Futura", 30))],
[sg.Text(" ", font = ("Futura", 30))],
[sg.Button("Staff", font = ("Futura", 30), size = (20, 1), key = "-Staff-")],
[sg.Button("Freshmen", font = ("Futura", 30), size = (20, 1), key = "-Freshmen-")]
]
mainLayout = [
[sg.VPush()],
[sg.Push(), sg.Column(mainElements, element_justification = "c"), sg.Push()],
[sg.VPush()]
]
window = sg.Window("Registration System", mainLayout, size = (800, 600))
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
if event == "-Staff-":
window.hide()
SearchWindow(sheet["CheckInStaff"])
window.un_hide()
if event == "-Freshmen-":
window.hide()
FreshmenWindow(sheet["CheckInFreshmen"])
window.un_hide()
window.close()
if __name__ == "__main__":
main()