-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgui.py
510 lines (421 loc) · 26.1 KB
/
gui.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
"""
This is the GUI module.
In this module are all GUI frames
"""
# Imports
import tkinter as tk
from tkinter import ttk
from PIL import Image, ImageTk
from programming_main import *
from tkinter import messagebox
import re
# Vars for the style
LARGE_FONT = ("Verdana", 12)
background_color = "#F6D03F"
button_background_color = "#1D0065"
button_foreground_color = "white"
button_active_background_color = "#005ca0"
# example code = 8470486
# example bday = 15-04-1998
class NSFietsenstalling(tk.Tk):
"""
This is the main class.
Within this class there is a dictionary for the static frames, and 2 functions for the dynamic frames.
Also there is some initialization for the whole application.
"""
def __init__(self, *args, **kwargs):
# Initialization for the whole application
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.iconbitmap(self, default="favicon.png")
tk.Tk.wm_title(self, "NS-Fietsenstalling")
tk.Tk.wm_geometry(self, "700x455") #start screen diameters
#tk.Tk.resizable(self, False, False)
self.container = tk.Frame(self)
self.container.pack(side="top", fill="both", expand=True)
self.container.grid_rowconfigure(0, weight=1)
self.container.grid_columnconfigure(0, weight=1)
# Dictionary for the static frames
self.frames = {}
for F in (StartPage, RegisterPage, StallPage, PickupPage, InfoPage, PersonalInfoPage):
frame = F(self.container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StartPage)
def show_frame(self, cont):
"""
Show the frame which is selected from the dictionary.
The requested frame is the cont parameter.
"""
frame = self.frames[cont]
frame.tkraise()
def showDisplayFrame(self, code, bday):
"""
Makes a new frame for the personal information page.
Needed a special function because there is dynamic content on the page (personal information).
"""
frame = PersonalInfoDisplayer(self.container, self, code, bday)
frame.grid(row=0, column=0, sticky="nsew")
frame.tkraise()
def showInfoPage(self):
"""
Makes a new frame for the general information page.
Needed a special function because there is dynamic content on the page (amount of stored bikes).
"""
frame = GeneralInfoPage(self.container, self)
frame.grid(row=0, column=0, sticky="nsew")
frame.tkraise()
class StartPage(tk.Frame):
"""
Shows start page.
"""
def _resize_image(self, event):
"""
Function to resize the image.
"""
new_width = event.width
new_height = event.height - 10
self.image = self.img_copy.resize((new_width, new_height))
self.photoholder = ImageTk.PhotoImage(self.image)
self.photo.configure(image = self.photoholder)
def __init__(self, parent, controller):
"""
Initializes the page.
"""
self.image = Image.open("NS_new2.jpg")
self.img_copy = self.image.copy()
tk.Frame.__init__(self, parent)
# Backgound color
self.configure(background=background_color)
#Weight for column and row configure for better positioning on grid layout
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(1, weight=1)
self.grid_columnconfigure(2, weight=1, uniform="fred")
self.grid_columnconfigure(1, weight=1, uniform="fred")
self.grid_columnconfigure(3, weight=1, uniform="fred")
# Making the title label
titleLabel = ttk.Label(self, text="NS-Fietsenstalling", font=LARGE_FONT, background=background_color)
titleLabel.grid(row=0, column=0, columnspan=4, pady=10, padx=10)
#titelLabel = tk.Label(self, bg=background_color, anchor=tk.W, justify=tk.LEFT, text="NS-Fietsenstalling", font=LARGE_FONT)
#titelLabel.pack(pady=10, padx=10)
self.photoholder = ImageTk.PhotoImage(self.image)
self.photo = tk.Label(self, image=self.photoholder)
self.photo.image = self.photoholder
self.photo.grid(row=1, columnspan=4,column=0,sticky=tk.NSEW)
#self.photo.pack(side=tk.TOP, fill=tk.BOTH, expand=tk.YES)
self.photo.bind('<Configure>', self._resize_image)
# Making the buttons
registerButton = tk.Button(self, height=5, justify=tk.LEFT, bg=button_background_color, activebackground=button_active_background_color, fg=button_foreground_color, activeforeground=button_foreground_color, text="Registreer", command=lambda: controller.show_frame(RegisterPage))
stallButton = tk.Button(self, height=5, justify=tk.LEFT, bg=button_background_color, activebackground=button_active_background_color, fg=button_foreground_color, activeforeground=button_foreground_color, text="Stal fiets", command=lambda: controller.show_frame(StallPage))
pickupButton = tk.Button(self, height=5, justify=tk.LEFT, bg=button_background_color, activebackground=button_active_background_color, fg=button_foreground_color, activeforeground=button_foreground_color, text="Haal fiets op", command=lambda: controller.show_frame(PickupPage))
infoButton = tk.Button(self, height=5, justify=tk.LEFT, bg=button_background_color, activebackground=button_active_background_color, fg=button_foreground_color, activeforeground=button_foreground_color, text="Informatie opvragen", command=lambda: controller.show_frame(InfoPage))
registerButton.grid(row=2, column=0, sticky=tk.NSEW)
stallButton.grid(row=2,column=1, sticky=tk.NSEW)
pickupButton.grid(row=2,column=2, sticky=tk.NSEW)
infoButton.grid(row=2,column=3, sticky=tk.NSEW)
#registerButton.pack(fill=tk.BOTH, side=tk.LEFT)
#stallButton.pack(fill=tk.BOTH, side=tk.LEFT)
#pickupButton.pack(fill=tk.BOTH, side=tk.LEFT)
#infoButton.pack(fill=tk.BOTH, side=tk.LEFT)
class RegisterPage(tk.Frame):
"""
Shows the register page.
"""
def __init__(self, parent, controller):
"""
Initializes the page.
"""
tk.Frame.__init__(self, parent)
# Making a var for the radiobuttons
sex = tk.IntVar()
# Backgound color
self.configure(background=background_color)
# Weight for column and row configure for better positioning on grid layout
self.grid_columnconfigure(0, weight=1)
self.grid_columnconfigure(1, weight=1)
self.grid_columnconfigure(2, weight=1)
self.grid_rowconfigure(7, weight=1)
# Making the title label
titleLabel = ttk.Label(self, text="NS-Fietsenstalling", font=LARGE_FONT, background=background_color)
titleLabel.grid(row=0, column=0, columnspan=3, pady=10, padx=10)
# Input for registering
# Inputs: Name, Tel, Sex, Bday
nameEntryLabel = tk.Label(self, background=background_color, text="Naam (ex. Jan Janssen):")
nameEntry = tk.Entry(self)
telEntryLabel = tk.Label(self, background=background_color, text="Telefoonnummer (ex. +31612345678):")
telEntry = tk.Entry(self)
sexLabel = tk.Label(self, background=background_color, text="Geslacht:")
sexButtonMan = tk.Radiobutton(self, bg=background_color, activebackground=background_color, text="Man", value=1, variable=sex)
sexButtonWoman = tk.Radiobutton(self, bg=background_color, activebackground=background_color, text="Vrouw", value=0, variable=sex)
bdayEntryLabel = tk.Label(self, background=background_color, text="Geboortedatum (ex. 01-01-2001):")
bdayEntry = tk.Entry(self)
mailEntryLabel = tk.Label(self, background=background_color, text="E-Mail (ex. [email protected]):")
mailEntry = tk.Entry(self)
registerButton = tk.Button(self, bg=button_background_color, activebackground=button_active_background_color, fg=button_foreground_color, activeforeground=button_foreground_color, height=4, width=30, relief="flat", text="Registreer", command=lambda: checkField(nameEntry.get(), telEntry.get(), sex.get(), bdayEntry.get(), mailEntry.get()))
registerButton.grid(row=6, column=0, columnspan=3, pady=30)
# Put all enties, radiobuttons and labels on grid
nameEntryLabel.grid(row=1, column=0, pady=10, padx=10, sticky=tk.E)
nameEntry.grid(row=1, column=1, sticky=tk.EW)
telEntryLabel.grid(row=2, column=0, pady=10, padx=10, sticky=tk.E)
telEntry.grid(row=2, column=1, sticky=tk.EW)
sexLabel.grid(row=3, column=0, pady=10, padx=10, sticky=tk.E)
sexButtonMan.grid(row=3, column=1, sticky=tk.W)
sexButtonWoman.grid(row=3, column=1)
bdayEntryLabel.grid(row=4, column=0,pady=10, padx=10, sticky=tk.E)
bdayEntry.grid(row=4, column=1, sticky=tk.EW)
mailEntryLabel.grid(row=5, column=0, pady=10, padx=10, sticky=tk.E)
mailEntry.grid(row=5, column=1, sticky=tk.EW)
# Home buttton
homeButton = tk.Button(self, height=4, text="Naar beginscherm", bg=button_background_color, activebackground=button_active_background_color, fg=button_foreground_color, activeforeground=button_foreground_color, relief="flat", command=lambda: controller.show_frame(StartPage))
homeButton.grid(row=7, column=0, columnspan=3, sticky=tk.EW+tk.S)
def checkField(name, tel, sex, bday, mail):
# Check if all fields are filled in correctly
if name == "" or tel == "" or bday == "" or mail == "":
# Popup if name, tel, bday or mail is not filled in
tk.messagebox.showerror("Oops", "Vul alle velden in")
else:
# Do regex check to see if the filled in fields corrensponds with the example
matchBday = re.match('\d{2}-\d{2}-\d{4}', bday)
matchTel = re.match('\+\d{11}', tel)
matchMail = re.match('.*@.*\.*.', mail)
if matchBday and matchTel and matchMail:
# Popup if regex checks failed (preventing errors in the next step)
if matchBday.group(0) == bday and matchTel.group(0) == tel and matchMail.group(0) == mail:
# Send vars to programming_main, clear fields and go to StartScreen if regex checks are the same as the inputs
nameEntry.delete(0, tk.END)
telEntry.delete(0, tk.END)
bdayEntry.delete(0, tk.END)
mailEntry.delete(0, tk.END)
code = Register(name, tel, sex, bday, mail)
tk.messagebox.showinfo("Code", "Uw persoonlijke code is: " + str(code) + "\nDeze staat ook in uw mail.")
controller.show_frame(StartPage)
else:
tk.messagebox.showerror("Oops", "Vul alle velden in zoals de voorbeelden")
else:
tk.messagebox.showerror("Oops", "Vul alle velden in zoals de voorbeelden")
class StallPage(tk.Frame):
"""
Shows the stall page.
"""
def StallBike(self, controller, code, bday):
# Get input and clear text fields
code_text = code.get("1.0", tk.END)[:-1]
bday_text = bday.get("1.0", tk.END)[:-1]
bday.delete("1.0", tk.END)
code.delete("1.0", tk.END)
#Check authentication
if CheckAuth(code_text, bday_text):
if(Stall(code_text) == 0):
# Let the user know the bike is stored
LogAction("Er is een fiets geplaatst onder code:"+code_text)
details = GetMailFromCode(code_text)
SendMessage(details[0], "Beste "+details[1]+",\n\nUw fiets is zojuist aangemeld bij ons.\nWe wensen u een fijne reis!\n\nWe hopen u voldoende informatie te hebben verstrekt,\nHet NS team.")
messagebox.showinfo("Success", message="Uw fiets is aangemeld in ons systeem!\nTot snel!")
else:
# Let the user know only 1 bike can be stored at the same time
messagebox.showerror("Helaas...", message="U heeft al een fiets aangemeld staan.\nHelaas kunt u maar 1 fiets aanmelden.")
controller.show_frame(StartPage)
else:
# Let the user know the authentication failed
messagebox.showerror("Ongeldig", message="Ongeldige code / geboortedatum combinatie")
def __init__(self, parent, controller):
"""
Initializes the page.
"""
tk.Frame.__init__(self, parent)
# Backgound color
self.configure(background=background_color)
# Weight for column and row configure for better positioning on grid layout
self.grid_columnconfigure(0, weight=1)
self.grid_columnconfigure(1, weight=1)
self.grid_rowconfigure(5, weight=1)
# Making al the GUI elements
titleLabel = ttk.Label(self, text="NS-Fietsenstalling", font=LARGE_FONT, background=background_color).grid(row=0, pady=10, padx=10, columnspan=3)
codeLabel = ttk.Label(self, text="Uw unieke nummer (ex. 6658469):", background=background_color).grid(row=1, column=0, sticky=tk.E)
code = tk.Text(self, height=1, width=15)
code.grid(row=1, pady=10, padx=10,column=1, sticky=tk.W)
bdayLabel = ttk.Label(self, text="Uw geboortedatum (ex. 15-04-1998):", background=background_color).grid(row=2, column=0, sticky=tk.E)
bday = tk.Text(self, height=1, width=15)
bday.grid(row=2, pady=10, padx=10, column=1, sticky=tk.W)
stallButton = tk.Button(self, height=4, width=30, text="Zet fiets in stalling", background=button_background_color, activebackground=button_active_background_color, foreground=button_foreground_color, activeforeground=button_foreground_color, relief="flat", command=lambda: self.StallBike(controller, code, bday))
stallButton.grid(row=3, column=0, columnspan=3, pady=30)
homeButton = tk.Button(self, height=4, text="Naar beginscherm", background=button_background_color, activebackground=button_active_background_color, foreground=button_foreground_color, activeforeground=button_foreground_color, relief="flat", command=lambda: controller.show_frame(StartPage))
homeButton.grid(row=5, column=0, columnspan=3, sticky=tk.EW+tk.S)
#homeButton.pack(fill=tk.BOTH,side=tk.BOTTOM)
class PickupPage(tk.Frame):
"""
Shows the pickup page.
"""
def RemoveBike(self, controller, code, bday):
# Get input and clear text fields
code_text = code.get("1.0", tk.END)[:-1]
bday_text = bday.get("1.0", tk.END)[:-1]
bday.delete("1.0", tk.END)
code.delete("1.0", tk.END)
if CheckAuth(code_text, bday_text):
if BikePickup(code_text) == 0:
LogAction("Er is een fiets verwijderd onder code:"+code_text)
details = GetMailFromCode(code_text)
SendMessage(details[0], "Beste "+details[1]+",\n\nUw fiets is zojuist afgemeld bij ons.\nHopelijk tot snel!\n\nWe hopen u voldoende informatie te hebben verstrekt,\nHet NS team.")
messagebox.showinfo("Success", message="Uw fiets is afgemeld in ons systeem!\nVeel rijdplezier.")
else:
messagebox.showerror("Helaas", message="U had uw fiets al opgehaald.\nDronken avond gehad?")
controller.show_frame(StartPage)
else:
messagebox.showerror("Ongeldig", message="Ongeldige code / geboortedatum combinatie")
def __init__(self, parent, controller):
"""
Initializes the page.
"""
tk.Frame.__init__(self, parent)
# Backgound color
self.configure(background=background_color)
# Weight for column and row configure for better positioning on grid layout
self.grid_columnconfigure(0, weight=1)
self.grid_columnconfigure(1, weight=1)
self.grid_rowconfigure(5, weight=1)
# Making all the GUI elements
titleLabel = ttk.Label(self, text="NS-Fietsenstalling", font=LARGE_FONT, background=background_color).grid(row=0, pady=10, padx=10, columnspan=3)
codeLabel = ttk.Label(self, text="Uw unieke nummer (ex. 6658469):", background=background_color).grid(row=1,column=0, sticky=tk.E)
code = tk.Text(self, height=1, width=15)
code.grid(row=1, pady=10, padx=10,column=1, sticky=tk.W)
bdayLabel = ttk.Label(self, text="Uw geboortedatum (ex. 15-04-1998):", background=background_color).grid(row=2, column=0, sticky=tk.E)
bday = tk.Text(self, height=1, width=15)
bday.grid(row=2, pady=10, padx=10,column=1, sticky=tk.W)
stallButton = tk.Button(self, height=4, width=30, text="Haal fiets op", background=button_background_color, activebackground=button_active_background_color, foreground=button_foreground_color, activeforeground=button_foreground_color, relief="flat", command=lambda: self.RemoveBike(controller, code, bday))
stallButton.grid(row=3, column=0, columnspan=3, pady=30)
homeButton = tk.Button(self, height=4, text="Naar beginscherm", background=button_background_color, activebackground=button_active_background_color, foreground=button_foreground_color, activeforeground=button_foreground_color, relief="flat", command=lambda: controller.show_frame(StartPage))
homeButton.grid(row=5, column=0, columnspan=3, sticky=tk.EW+tk.S)
#homeButton.pack(fill=tk.BOTH,side=tk.BOTTOM)
class InfoPage(tk.Frame):
"""
Shows the info page.
"""
def __init__(self, parent, controller):
"""
Initializes the page.
"""
tk.Frame.__init__(self, parent)
# Backgound color
self.configure(background=background_color)
# Weight for column and row configure for better positioning on grid layout
self.grid_columnconfigure(0, weight=1)
self.grid_columnconfigure(1, weight=1)
self.grid_rowconfigure(1, weight=1)
self.grid_rowconfigure(2, weight=1)
# Making all the GUI elements
titleLabel = ttk.Label(self, text="NS-Fietsenstalling", font=LARGE_FONT, background=background_color)
titleLabel.grid(row=0, column=0, columnspan=2, pady=10, padx=10)
GeneralInfoButton = tk.Button(self, height=4, background=button_background_color, activebackground=button_active_background_color, foreground=button_foreground_color, activeforeground=button_foreground_color, relief="flat", text="Algemene informatie", command=lambda: controller.showInfoPage())
GeneralInfoButton.grid(row=1, column=0, padx=10, pady=10, sticky=tk.EW+tk.S)
personalInfoButton = tk.Button(self, height=4, background=button_background_color, activebackground=button_active_background_color, foreground=button_foreground_color, activeforeground=button_foreground_color, relief="flat", text="Persoonlijke informatie", command=lambda: controller.show_frame(PersonalInfoPage))
personalInfoButton.grid(row=1, column=1, padx=10, pady=10, sticky=tk.EW+tk.S)
homeButton = tk.Button(self, height=4, text="Naar beginscherm", background=button_background_color, activebackground=button_active_background_color, foreground=button_foreground_color, activeforeground=button_foreground_color, relief="flat", command=lambda: controller.show_frame(StartPage))
homeButton.grid(row=2, column=0, columnspan=2, sticky=tk.EW+tk.S)
class GeneralInfoPage(tk.Frame):
"""
Shows the general info page.
"""
def __init__(self, parent, controller):
"""
Initializes the page.
"""
tk.Frame.__init__(self, parent)
# Backgound color
self.configure(background=background_color)
# Weight for column and row configure for better positioning on grid layout
self.grid_columnconfigure(0, weight=1)
self.grid_columnconfigure(1, weight=1)
self.grid_rowconfigure(4, weight=1)
operating_details = GetInfo()
# Making all the GUI elements
titleLabel = ttk.Label(self, text="NS-Fietsenstalling", font=LARGE_FONT, background=background_color).grid(row=0, pady=10, padx=10, columnspan=2)
statusLabel = ttk.Label(self, text="Systeem status:", background=background_color).grid(row=1, column=0, sticky=tk.E)
status2Label = ttk.Label(self, text=operating_details['system_status'], background=background_color).grid(row=1, column=1, sticky=tk.W)
counterLabel = ttk.Label(self, text="Aantal plaatsen bezet:", background=background_color).grid(row=2, column=0, sticky=tk.E)
counter2Label = ttk.Label(self, text=str(operating_details['counter'])+" / " + str(operating_details['total_places']), background=background_color).grid(row=2,column=1, sticky=tk.W)
copyright = ttk.Label(self, text="Gemaakt door Sjoerd, Max, Hidde, Vincent en Tristan", background=background_color).grid(row=3,column=0, pady=20, columnspan=2)
homeButton = tk.Button(self, height=4, text="Naar beginscherm", background=button_background_color, activebackground=button_active_background_color, foreground=button_foreground_color, activeforeground=button_foreground_color, relief="flat", command=lambda: controller.show_frame(StartPage))
homeButton.grid(row=4, column=0, columnspan=2, sticky=tk.EW+tk.S)
class PersonalInfoDisplayer(tk.Frame):
"""
Shows the personal info page.
"""
def __init__(self, parent, controller, code, bday):
"""
Initializes the page.
"""
tk.Frame.__init__(self, parent)
# Get input and clear text fields
code_text = code.get("1.0", tk.END)[:-1]
bday_text = bday.get("1.0", tk.END)[:-1]
bday.delete("1.0", tk.END)
code.delete("1.0", tk.END)
details = GetUserInfo(code_text, bday_text)
print(details)
if len(details) == 0:
messagebox.showerror("Ongeldig", message="Ongeldige code / geboortedatum combinatie")
controller.show_frame(StartPage)
else:
print("Fissa!!")
# Backgound color
self.configure(background=background_color)
# Weight for column and row configure for better positioning on grid layout
self.grid_columnconfigure(0, weight=1)
self.grid_columnconfigure(1, weight=1)
self.grid_rowconfigure(6, weight=1)
# Making all the GUI elements
titleLabel = ttk.Label(self, text="NS-Fietsenstalling", font=LARGE_FONT, background=background_color)
titleLabel.grid(row=0,pady=10, padx=10,columnspan=2)
nameLabel = ttk.Label(self, text="Uw naam:", background=background_color).grid(row=1, column=0, sticky=tk.E)
name = ttk.Label(self, text=details[1], background=background_color).grid(row=1,column=1, sticky=tk.W)
phoneLabel = ttk.Label(self, text="Uw telefoonnummer:", background=background_color).grid(row=2 , column=0, sticky=tk.E)
phone = ttk.Label(self, text=details[2], background=background_color).grid(row=2, column=1, sticky=tk.W)
sexLabel = ttk.Label(self, text="Uw geslacht:", background=background_color).grid(row=3, column=0, sticky=tk.E)
if details[3]:
sexval = "man"
else:
sexval = "vrouw"
sex = ttk.Label(self, text=sexval, background=background_color).grid(row=3,column=1, sticky=tk.W)
bdayLabel = ttk.Label(self, text="Uw geboortedatum:", background=background_color).grid(row=4, column=0, sticky=tk.E)
bdayText = ttk.Label(self, text=details[4], background=background_color).grid(row=4,column=1, sticky=tk.W)
bdayLabel = ttk.Label(self, text="Uw fietscode:", background=background_color).grid(row=5, column=0, sticky=tk.E)
bdayText = ttk.Label(self, text=str(details[5]), background=background_color).grid(row=5, column=1, sticky=tk.W)
homeButton = tk.Button(self, height=4, text="Naar beginscherm", background=button_background_color, activebackground=button_active_background_color, foreground=button_foreground_color, activeforeground=button_foreground_color, relief="flat", command=lambda: controller.show_frame(StartPage))
homeButton.grid(row=6, column=0, columnspan=2, sticky=tk.EW+tk.S)
class PersonalInfoPage(tk.Frame):
"""
Show the personal info page (Inputs).
"""
def __init__(self, parent, controller):
"""
Initializes the page.
"""
tk.Frame.__init__(self, parent)
# Backgound color
self.configure(background=background_color)
# Weight for column and row configure for better positioning on grid layout
self.grid_columnconfigure(0, weight=1)
self.grid_columnconfigure(1, weight=1)
self.grid_rowconfigure(5, weight=1)
# Making all the GUI elements
titleLabel = ttk.Label(self, text="NS-Fietsenstalling", font=LARGE_FONT, background=background_color).grid(row=0, pady=10, padx=10, columnspan=2)
codeLabel = ttk.Label(self, text="Uw unieke nummer (ex. 6658469):", background=background_color)
codeLabel.grid(row=1,column=0, sticky=tk.E)
code = tk.Text(self, height=1, width=15)
code.grid(row=1, pady=10, padx=10, column=1, sticky=tk.W)
bdayLabel = ttk.Label(self, text="Uw geboortedatum (ex. 15-04-1998):", background=background_color)
bdayLabel.grid(row=2, column=0, sticky=tk.E)
bday = tk.Text(self, height=1, width=15)
bday.grid(row=2,pady=10, padx=10, column=1, sticky=tk.W)
homeButton = tk.Button(self, height=4, text="Naar beginscherm", background=button_background_color, activebackground=button_active_background_color, foreground=button_foreground_color, activeforeground=button_foreground_color, relief="flat", command=lambda: controller.show_frame(StartPage))
homeButton.grid(row=5, column=0, columnspan=2, sticky=tk.EW+tk.S)
infoButton = tk.Button(self, height=4, width=30, text="Bekijk info", background=button_background_color, activebackground=button_active_background_color, foreground=button_foreground_color, activeforeground=button_foreground_color, relief="flat", command=lambda: controller.showDisplayFrame(code,bday))
infoButton.grid(row=3, column=0, columnspan=2, pady=30)
# Run the application
app = NSFietsenstalling()
app.mainloop()
"""
Using lambda for the buttoncommands.
Without lambda the button press didn't do anything.
Using grid instead of pack to make a better layout.
"""