· 6 years ago · Nov 04, 2019, 06:16 PM
1 #import appropriate libraries from python
2from tkinter import *
3#tkinter allows us to create GUI's
4import csv
5import sys
6#sys allows us to kill the program
7import random
8#allows us to create a random number for the Pupil ID
9import tkinter.simpledialog
10#this library allows us to make messege boxes
11from tkinter import messagebox
12from tkinter import ttk
13import datetime
14import math
15
16#all functions for the program wiil be written here
17####################################################################################################################################
18
19#function name: raise_frame
20#reason: this will raise a particular frame to allow it to be viewed by the user
21#returns: no returns
22#perameter: name of the frame the user want to see
23def raise_frame(frame_name):
24 frame_name.tkraise()
25####################################################################################################################################
26#clear_button
27 #clear username and password
28 #returns: none
29 #parameters: none
30def login_clear_button():
31 username.set("")
32 password.set("")
33####################################################################################################################################
34#login_help
35 #reason
36 #return: none
37 #parameters: none
38
39def login_help():
40 messagebox.showinfo("User informtion", "Please fill in your username and password", icon = "info")
41####################################################################################################################################
42
43 #login_submit
44 #reason: logs the user into the menu
45 #returns:none
46 #parameters:none
47 #look at data thats been entered
48def login_submit():
49 login_username = username.get()
50 login_password = password.get()
51
52 if(login_username == "" or login_password == "" or login_username.isnumeric() == True or login_password.isnumeric() == True):
53 messagebox.showinfo("User information", "Invalid data entered", icon = "warning")
54 username.set
55 #this is the code for a presence check
56
57
58 #access username and password file
59 else:
60 with open("usernamesandpasswords.txt","r") as csvfile:
61
62#making a variable called found to test if its found the record or not
63
64 found = 0
65 reader = csv.reader(csvfile)
66 for row in reader:
67 if(login_username == row[0] and login_password == row[1]):
68 raise_frame(menu_frame)
69 found = 1
70
71 username.set('')
72 password.set('')
73 csvfile.close()
74
75 if(found == 0):
76 messagebox.showinfo("User information", login_username + "does not exist", icon = "error")
77 login_clear_button()
78
79
80def add_pupil_details():
81#.get all the information from the screen
82 afirstname = firstname.get()
83 asurname = surname.get()
84 #.get both parts of the email
85 aemail = email.get()
86 aemailaddress = emailaddress.get()
87 fullemail = aemail + aemailaddress
88 print(fullemail)
89
90 #
91 pup_age=age_spin.get()
92
93 agender_choice = gender_choice.get()
94 #take the mobile data entered
95 amobile = mobile.get()
96 fullmobile = "44" + amobile
97
98#error checking
99 if(afirstname =="" or asurname=="" or aemail=="" or amobile==""):
100 print("Error")
101 messagebox.showerror("Error", "there was an issue with the inputted information")
102 firstname.set("")
103 surname.set("")
104 email.set("")
105 mobile.set("")
106
107 elif(agender_choice > 2):
108 print("Error 2")
109 messagebox.showerror("Error", "Please select a gender")
110 firstname.set("")
111 surname.set("")
112 email.set("")
113 mobile.set("")
114
115 elif(len(fullmobile)!=12):
116 print("Error 3")
117 messagebox.showerror("Error", "the mobile number entered is invalid")
118 firstname.set("")
119 surname.set("")
120 email.set("")
121 mobile.set("")
122
123
124 #confirm that the user wants to save this data
125 else:
126 result = messagebox.askquestion("submit", "You are about to enter the following data\n" + afirstname + "\n" + asurname + "\n" + fullemail + "\n")
127
128 #create unique
129 initial = afirstname[0]
130 id_number = random.randint(100,1000)
131 userid = str(id_number)
132
133 if(result == "yes"):
134 print("here")
135 #opens the usernamesandpasswords file and adds the new data
136 with open("add_details.txt" , "a") as csvfile:
137 writer = csv.writer(csvfile)
138 writer.writerow([userid,afirstname,asurname,fullemail,pup_age,agender_choice,amobile])
139 csvfile.close()
140 messagebox.showinfo("Information", "Your unique ID is " + userid)
141 else:
142 firstname.set("")
143 surname.set("")
144 email.set("")
145 mobile.set("")
146
147
148
149
150def display_ski_times():
151 #create an empty array called ski times
152 skitimesTV = []
153 #open the csv that contains the ski times and the average
154 with open ("skiandadverage.txt", "rU") as csvfile:
155 #place all the data in reader
156 reader = csv.reader(csvfile)
157 #go through reader
158 for row in reader:
159 #add the times into the array called skitimesTV
160 skitimesTV.append(row)
161 csvfile.close()
162 print(SkitimesTV)
163
164 #get all the data in the treeview called TimesTV
165 records = TimesTV.get_children()
166
167 #go through the tv and delete it
168 for elements in records:
169 TimesTV.delete(elements)
170
171 #go throught the data in the array ski times and insert it in the the TimesTV component
172 for row in skitimesTV:
173 TimesTV.insert("","end",text = row[0],values=(row[1],row[2],row[3],row[4],row[5]))
174
175 #create a word document
176 f = open("skitimes.docx","w")
177 #first line of the report
178 f.write("report name: Ski times" +"\n" + "\n")
179 #get the current date
180 now = datetime.datetime.now()
181 #in the document write the date
182 f.write("Date: "+str(now.day) +"/" +str(now.month) + str(now.year) +"\n")
183 #write the headings adding in tab to format this line
184 f.write("Position" + "\t"+"PupilName" +"\t" + "Times" + "\n")
185 f.write("\n")
186 #
187 position = 1
188 #we are going to list the variables
189 for i in skitimesTV:
190
191 #write the value of the position, which say the times
192 f.write(str(position) + "\t" + "\t")
193 #write the student ID
194 f.write(i[0]+ "\t" + "\t")
195 #write the time and move on to the next
196 f.write(i[3] + "\n")
197 f.write("\n")
198 #increase the value by one
199 position = position + 1
200 f.close()
201
202def display_ski_time_W():
203 print("here")
204 ########################################
205#---------------------------------------------------------------------------------------------------------------
206#for the ages report
207
208
209def display_pupil_ages():
210 #create an empty array called ages_report_frame
211 ages_report_frame = []
212 #open the csv that contains the pupil ages
213 with open ("add_details.txt", "rU") as csvfile:
214 #place all the data in reader
215 reader = csv.reader(csvfile)
216 #go through reader
217 for row in reader:
218 #add the times into the array called ages_report_frame
219 ages_report_frame.append(row)
220 csvfile.close()
221 print(ages_report_frame)
222
223 #get all the data in the treeview called AgesTV
224 records = AgesTV.get_children()
225
226 #go through the tv and delete it
227 for elements in records:
228 AgesTV.delete(elements)
229
230 #go throught the data in the array and insert it in the the AgesTV component
231 for row in ages_report_frame:
232 AgesTV.insert("","end",text = row[0],values=(row[1],row[2],row[3],row[4],row[5]))
233
234
235 position = 1
236 #we are going to list the variables
237 for i in age_report_frame:
238
239 #write the value of the position, which say the Ages
240 f.write(str(position) + "\t" + "\t")
241 #write the pupil ID
242 f.write(i[0]+ "\t" + "\t")
243 #write the time and move on to the next
244 f.write(i[3] + "\n")
245 f.write("\n")
246 #increase the value by one
247 position = position + 1
248 f.close()
249
250#--------------------------------------------------------------------------------------
251def help_AgesRep():
252 messagebox.showinfo('Help','Please press the "Ages of the Pupils" button',icon='info')
253
254
255
256
257
258
259
260###############################################################################################################
261#menu_help
262#reason:to assist confused users
263#returns: none
264#parameters: none
265
266def menu_help():
267 messagebox.showinfo("User informtion", "Please select an option from this menu", icon = "info")
268
269#summary1_button
270 #reason:give a summary
271 #returns:none
272 #parameters:none
273def summary1_button():
274 raise_frame(SkitimesTV)
275
276
277#summary2_button
278 #reason:give a summary
279 #returns none
280 #parameters:none
281def summary2_button():
282 raise_frame(age_report_frame)
283
284
285
286#back_menu
287 #reason:to allow the user to go back
288 #returns:none
289 #parameters:none
290def back_menu():
291 raise_frame(login_frame)
292
293#add_pupil
294 #reason:to add pupil lists
295 #returns:none
296 #parameters:none
297def add_pupil():
298 raise_frame(pupilentry_frame)
299
300#pupil_groups
301#reason:easy to understand the skill groups
302#returns:none
303#parameters:none
304def find_student():
305 entered_id=id_pup.get()
306 _entered_slope_time_1=slope_1_time.get()
307 _entered_slope_time_2=slope_2_time.get()
308 _entered_slope_time_3=slope_3_time.get()
309 _entered_slope_time_4=slope_4_time.get()
310 _entered_slope_time_5=slope_5_time.get()
311
312 entered_slope_time_1=int(_entered_slope_time_1)
313 entered_slope_time_2=int(_entered_slope_time_2)
314 entered_slope_time_3=int(_entered_slope_time_3)
315 entered_slope_time_4=int(_entered_slope_time_4)
316 entered_slope_time_5=int(_entered_slope_time_5)
317
318 with open('add_details.txt', 'rU') as csvfile:
319 reader = csv.reader(csvfile)
320 for row in reader:
321 if row ==[]:
322 pass
323 elif row[0] == entered_id:
324 checked_entered_id =entered_id
325 firstname = row[1]
326
327
328 total_time=(entered_slope_time_1+entered_slope_time_2+entered_slope_time_3+entered_slope_time_4+entered_slope_time_5)
329 avg_time=total_time/5
330 with open('time_1.txt', 'a') as csvfile:
331 writer = csv.writer(csvfile)
332 writer.writerow([checked_entered_id,firstname,avg_time])
333 csvfile.close()
334 messagebox.showinfo("Average time", "Average time is "+checked_entered_id, icon = "info")
335
336
337
338
339def back():
340 raise_frame(menu_frame)
341
342def pupil_groups():
343 raise_frame(pupil_groups_frame)
344
345
346def find_skill_group():
347
348 #get the name of the group from the list
349 Group_choice = Group.get()
350 all_selected=0
351 if Group_choice == 'All':
352 all_selected=1
353
354 #Create an empty array called pupils
355 #I will go through the file and pick out all of these pupils
356 pupils_array = []
357
358 #open the file contains all of the pupils scores
359 with open('skillgroups.txt', 'rU') as csvfile:
360 #place all of the data inside a variable called reader
361 reader = csv.reader(csvfile)
362
363 found_id=0
364 #go through the variable reader
365 for row in reader:
366 #if a row is empty pass by it not causing an error
367 #Solves the list index out of range error
368 if len(row) and row == []:
369 found_id=1
370 pass
371 #compare the golfers country to the country selected
372 if all_selected==0:
373 pupils_array.append(row)
374 if len(row) and row[2] == Group_choice and found_id==0 and all_selected==0:
375 #add the golfers record into the array called student marks
376 pupils_array.append(row)
377 # if len(row) and row[2] == 'Advanced' and found_id==0 and all_selected==0:
378 # pupils_array.append(row)
379 # if len(row) and row[2] == 'Beginner' and found_id==0 and all_selected==0:
380 # pupils_array.append(row)
381
382
383 #else:
384 # #compare the golfers country to the country selected
385 # if row[2] == Group_choice:
386 # #add the golfers record into the array called student marks
387 # pupils_array.append(row)
388 csvfile.close()
389 print(pupils_array)
390
391 #get all of the data from the treeview called scoreTV
392 records = TimesTV.get_children()
393
394 #go through the data in the treeview and delete it
395 for elements in records:
396 hGroupTV.delete(elements)
397
398 #go through the data in the array golfers and insert it into the Treeview component called scoreTV
399 for row in pupils_array:
400 hGroupTV.insert('','end',text = row[0],values=(row[1],row[2], row[3], row[4], row[5], row[6], row[7]))
401
402 #We now have the records from the csv file and they have been ordered
403 #We are now going to write this ordered list to a file
404 #We are also going to display all of the results in the Listbox we created
405
406 #Create the word document and open it in write mode
407 f = open("skillgroups.docx", "w")
408 #Write in the first line of the report
409 f.write("Report Name: Pupils" +"\n" + "\n")
410 #Get the current date this contains all the aspect of the date including date and time
411 now = datetime.datetime.now()
412 #In the report document write the date
413 f.write("Date: "+str(now.day) +"/" + str(now.month) + "/" +str(now.year) +"\n")
414 #In the report document write the headings adding in tab to format this line
415 f.write("First Name" +"\t" + "Surname" +"\n")
416 f.write("\n")
417
418 #we are going through the list and the variable i will take on the data in each part of the list as we go through the for loop
419 for i in pupils_array:
420
421 #Write the first name and use tabs to space it out properly
422 f.write(i[0]+ "\t" + "\t")
423 #Write the surname and use new line to move onto the next line in the file
424 f.write(i[1] +"\n")
425 f.write("\n")
426
427 f.close()
428
429#############################################################################################################################
430#def pupil_skill_groupsL2H():
431
432 #Create an empty array called pupils
433 #I will go through the file and places all of the pupils
434 # pupils_array = []
435
436 #open the file contains all of the pupils groups
437 # with open('skillgroups.txt', 'rU') as csvfile:
438 #place all of the data inside a variable called reader
439 # reader = csv.reader(csvfile)
440 #go through the variable reader
441 # for row in reader:
442 #if a row is empty pass by it not causing an error
443 # if row == []:
444 # pass
445 # else:
446 #add the pupils record into the array called skill groups
447# pupils_array.append(row)
448 # csvfile.close()
449 # print(pupils_array)
450
451 #get all of the data from the treeview called TimesTV
452 # records = TimesTV.get_children()
453
454 #go through the data in the treeview and delete it
455 # for elements in records:
456 # TimesTV.delete(elements)
457
458 #we are now going to sort the list based upon the pupils
459# total = lambda pupils_array: pupils_array[4]
460 #we are going to sort the list from biggest to smallest
461# pupils_array.sort(key=total, reverse = True)
462
463 #go through the data in the array golfers and insert it into the Treeview component called scoreTV
464# for row in pupils_array:
465 # TimesTV.insert('','end',text = row[0],values=(row[1],row[2], row[3], row[4], row[5], row[6], row[7]))
466
467 #We now have the records from the csv file and they have been ordered
468 #We are now going to write this ordered list to a file
469 #We are also going to display all of the results in the Listbox we created
470
471 #Create the word document and open it in write mode
472 # f = open("skillgroups.docx", "w")
473 #Write in the first line of the report
474 # f.write("Report Name: pupils" +"\n" + "\n")
475 #Get the current date this contains all the aspect of the date including date and time
476# now = datetime.datetime.now()
477 #In the report document write the date
478 # f.write("Date: "+str(now.day) +"/" + str(now.month) + "/" +str(now.year) +"\n")
479 #In the report document write the headings adding in tab to format this line
480 # f.write("First Name" +"\t" + "Surname" +"\n")
481 # f.write("\n")
482
483 #we are going through the list and the variable i will take on the data in each part of the list as we go through the for loop
484 # for i in pupils_array:
485
486 #Write the first name and use tabs to space it out properly
487 # f.write(i[0]+ "\t" + "\t")
488 #Write the surname and use new line to move onto the next line in the file
489 ## f.write(i[1] +"\n")
490 # f.write("\n")
491
492 # f.close()
493#####################################################################################################################################################################################################
494
495#ski_slopes
496 #reason:gives info
497 #returns:none
498 #parameters:none
499def ski_slopes():
500 raise_frame(ski_slopes_frame)
501
502 #reason:to allow the user to add a pupil to the file
503 #returns:none
504 #parameters:none
505def pupil_entry_frame():
506 raise_frame(pupilentry_frame)
507
508def AddP_clear_button():
509 firstname.set("")
510 surname.set("")
511 email.set("")
512 mobile.set("")
513
514def back_addp():
515 raise_frame(menu_frame)
516
517#reason:to find the desired pupil
518 #returns:none
519 #parameters:none
520def findpupil():
521 apupil_entername = pupil_entername.get()
522
523def findp_help():
524 messagebox.showinfo("User informtion", "Please enter the ID of the pupil", icon = "info")
525
526
527#reason:to display the skill groups
528 #returns:none
529 #parameters:none
530def pupilskillgroups():
531 raise_frame(pupil_skill_groups)
532
533#reason:to assist in deciding groups
534 #returns:none
535 #parameters:none
536def pupilquiz():
537 raise_frame(pupil_safety_quiz)
538
539#reason:to show the results the quiz
540 #returns:none
541 #parameters:none
542def Quiz_Results():
543 raise_frame(pupil_results)
544
545def help_QResults():
546 messagebox.showinfo('Help','Please press the "Show Results" button once you have chosen how you would like it to be displayed ',icon='info')
547
548
549def back_button_to_login():
550 back_response_times = messagebox.askquestion('Info','Are you sure you want to leave',icon='warning')
551 if (back_response_times == messagebox.YES):
552 raise_frame(login_frame)
553
554#A button to help the user on the add pupil frame
555def help_addp():
556 messagebox.showinfo('Help','Please enter in the required details',icon='info')
557
558#A button to help the user on the ski times report frame
559def help_repT():
560 messagebox.showinfo('Help','Please press the "Report By Ski Times" button',icon='info')
561
562#A button to help the user on the ski groups frame
563def help_Skigroups():
564 messagebox.showinfo('Help','Please select a Group from the dropdown menu, then press the "Find group" button',icon='info')
565
566#A button to help the user on the find student frame
567#def find_skill_group():
568# collected_group =group_type.get()
569
570#-----------------------------------------------------------------------------------------
571#quiz
572def back_for_quiz():
573 print("Back")
574
575def Help_quiz():
576 print("Help")
577
578#Function: submit_Quiz
579#Reason: This will change look at all of the selections that have been made and will create a score
580#Returns: None
581#Parameters: None
582def submit_quiz1():
583#look for the ID and make sure it's valid
584
585 ski_walk_answer = ski_walk_question.get()
586 print(ski_walk_answer)
587 ski_equip_answer = ski_equip_question.get()
588 ski_time_answer = ski_time_question.get()
589 ski_body_answer = ski_body_question.get()
590 ski_binding_answer = ski_binding_question.get()
591 ski_condition_answer = ski_condition_question.get()
592 ski_occur_answer = ski_occur_question.get()
593 ski_helmet_answer = ski_helmet_question.get()
594 ski_leave_answer = ski_leave_question.get()
595 ski_injury_answer = ski_injury_question.get()
596
597 if ski_walk_answer == "sideways" and ski_equip_answer == "Ski boots" and ski_time_answer == "Afternoon" and ski_body_answer == "Knees" and ski_binding_answer == "Its tension" and ski_condition_answer == "Dehydration" and ski_occur_answer == "Ones first time skiing" and ski_helmet_answer == "Always" and ski_leave_answer == "No" and ski_injury_answer == "Stop and tell the instructor":
598 print("here")
599 current_score.set("10")
600
601
602#Function: user_choice_button1
603#Reason: This will change take and the pupil option and change the score
604#Returns: None
605#Parameters: None
606def pupil_choice_button1():
607 pupil_score = current_score.get()
608 pupil_score = int(pupil_score)+1
609 print(pupil_score)
610 tkinter.messagebox.showinfo("Information", "Correct")
611 current_score.set(pupil_score)
612
613#Function: pupil_choice_button
614#Reason: This will change take and inform them that they are incorrect
615#Returns: None
616#Parameters: None
617def pupil_choice_button2():
618 tkinter.messagebox.showinfo("Information", "Incorrect, your score remains the same")
619
620#Function: pupil_choice_button
621#Reason: This will change take and inform them that they are incorrect
622#Returns: None
623#Parameters: None
624def pupil_choice_button3():
625 tkinter.messagebox.showinfo("Information", "Incorrect, your score remains the same")
626
627#Function: Raise Frame
628#Reason: This will change the Window/Frame that the user can see
629#Returns: None
630#Parameters: the name of the frame that you want to view
631def raise_frame(frame):
632 frame.tkraise()
633
634#Function: Start Quiz
635#Reason: This will take the user to the first part of the quiz
636#Returns: None
637#Parameters: none
638def start_quiz():
639 raise_frame(Question_frame1)
640 tkinter.messagebox.showinfo("Information", "Complete the first 5 multiple choice questions shown")
641
642def start_quiz2():
643 raise_frame(Question_frame2)
644 tkinter.messagebox.showinfo("Information", "Complete the next 5 multiple choice questions shown")
645
646
647#Function: Help Menu
648#Reason: This will send a message to the pupil about how to work the screen
649#Returns: None
650#Parameters: none
651def help_menu():
652 messagebox.showerror("Information", "Press the 'Click To Begin' button to start the quiz.")
653
654def help_quiz1():
655 messagebox.showerror("Information", "Please press the 'Select answer' buttons to answer the questions")
656
657#------------------------------------------------------------------------------------------
658#------------------------------------------------------------------------------------------
659#set up the GUI and cinfigure
660root = Tk()
661root.geometry("1000x720")
662#this will be how big the box will be
663root.title("gui title")
664root.config(bg='white')
665
666pupilsgroups = StringVar()
667
668#we will create the frames for the gui
669#frame for the login frame
670login_frame = Frame(root,width=1000,height=720,bg='white')
671
672#this will let the user imput their username and password
673menu_frame = Frame(root,width=1000,height=720,bg='white')
674
675#this frame will contain options for the staff or pupils to go to
676pupilentry_frame = Frame(root,width=1000,height=720,bg='white')
677
678#this frame will show the pupils groups
679pupil_groups_frame = Frame(root,width=1000,height=720,bg='white')
680
681#this is the frame for the tree view diagram
682SkitimesTV = Frame(root,width=1000,height=720,bg='white')
683
684#this is the frame for the pupil skill groups
685pupil_skill_groups = Frame(root,width=1000,height=720,bg='white')
686
687#frame fo the ski slopes
688ski_slopes_frame=Frame(root,width=1000,height=720,bg='white')
689
690#frame for the quiz
691pupil_safety_quiz = Frame(root,width=1000,height=720,bg='white')
692
693#frame for the pupil age report
694age_report_frame = Frame(root,width=1000,height=720,bg='white')
695
696#frame for the quiz results
697pupil_results = Frame(root,width=1000,height=720,bg='white')
698
699#frame for the quiz questions 1
700Question_frame1 = Frame(root,width=1000,height=720,bg='white')
701
702#frame for the seconed frame of questions
703Question_frame2 = Frame(root,width=1000,height=720,bg='white')
704
705
706#set up each frame to be gridded into rows and columns
707for frame in (login_frame, menu_frame, pupilentry_frame,ski_slopes_frame, pupil_groups_frame, SkitimesTV, pupil_skill_groups, pupil_safety_quiz, age_report_frame, pupil_results, Question_frame1, Question_frame2):
708 frame.grid(row = 0, column = 0, sticky = "news")
709
710
711#variable for the program
712#variables for the login frame
713username = StringVar()
714password = StringVar()
715
716#variable for the add pupil frame
717Name = StringVar()
718
719
720#------------------------------------------------------------------------------------------
721#------------------------------------------------------------------------------------------
722
723#variables for the login frame
724username = StringVar()
725password = StringVar()
726
727
728#components for each frame
729#components for the log in frame
730login_heading_labels = Label(login_frame, text = "Clarendon High School Login",bg='white',fg='#1874CD', font = ("Courier",45,"bold"))
731login_heading_labels.place(x=500,rely=0.1,anchor=CENTER)
732
733username_label = Label(login_frame, text = "Username: ",bg='white',fg='#1874CD',font = ("Courier",36,"bold"))
734username_label.place(x=375,rely=0.2,anchor=CENTER )
735
736username_entry = Entry(login_frame, textvariable = username,bg='#f8f8ff',font = ("Courier",28,"bold"),width=10)
737username_entry.place(x=625,rely=0.2,anchor=CENTER )
738
739password_label = Label( login_frame, text = "Password: ",bg='white',fg='#1874CD',font = ("Courier",36,"bold"))
740password_label.place(x=375,rely=0.29,anchor=CENTER )
741
742
743password_entry = Entry(login_frame, textvariable = password,bg='#f8f8ff', show = "*",font = ("Courier",28,"bold"),width=10)
744password_entry.place(x=625,rely=0.29,anchor=CENTER )
745
746
747login_clear_button = Button(login_frame, text = "Clear",bg='#f8f8ff',fg='#1874CD', command = login_clear_button,font = ("Courier",28,"bold"),width=5)
748login_clear_button.place(x=300,rely=0.4,anchor=CENTER )
749
750login_help_button = Button(login_frame, text = "Help",bg='#f8f8ff',fg='#1874CD', command = login_help,font = ("Courier",28,"bold"),width=5)
751login_help_button.place(x=450,rely=0.4,anchor=CENTER )
752
753login_submit_button = Button(login_frame, text = "Submit",bg='#f8f8ff',fg='#1874CD', command = login_submit,font = ("Courier",28,"bold"),width=9)
754login_submit_button.place(x=625,rely=0.4,anchor=CENTER)
755
756canvas = Canvas(login_frame, width = 500, height = 300, bg = "white")
757canvas.place(x=500,rely=0.7,anchor=CENTER)
758my_image = PhotoImage(file = "Skiingimage.png")
759canvas.create_image(0,0, anchor = NW, image = my_image)
760canvas.my_image = my_image
761#------------------------------------------------------------------------------------------
762#------------------------------------------------------------------------------------------
763
764#components for menu screen
765menu_title = Label(menu_frame, text = "Welcome to the Menu",bg='white',fg='#1874CD', font = ("Courier",48,"bold"))
766menu_title.place(x=500,rely=0.1,anchor=CENTER)
767
768summary1_button = Button(menu_frame, text = "Average times report", command = summary1_button,bg='#f8f8ff',fg='#1874CD',font = ("Courier",20,"bold"),width=30)
769summary1_button.place(x=500,rely=0.2,anchor=CENTER)
770
771summary2_button = Button(menu_frame, text = "Pupil Age Report", command = summary2_button,bg='#f8f8ff',fg='#1874CD',font = ("Courier",20,"bold"),width=30)
772summary2_button.place(x=500,rely=0.3,anchor=CENTER)
773
774add_pupil = Button(menu_frame, text = "Add Pupil", command = add_pupil,bg='#f8f8ff',fg='#1874CD',font = ("Courier",20,"bold"),width=30)
775add_pupil.place(x=500,rely=0.4,anchor=CENTER)
776
777ski_slopes = Button(menu_frame, text = "Ski Slopes Times", command = ski_slopes,bg='#f8f8ff',fg='#1874CD',font = ("Courier",20,"bold"),width=30)
778ski_slopes.place(x=500,rely=0.5,anchor=CENTER)
779
780pupilskillgroups = Button(menu_frame, text = "Skill groups", command = pupil_groups,bg='#f8f8ff',fg='#1874CD',font = ("Courier",20,"bold"),width=30)
781pupilskillgroups.place(x=500,rely=0.6,anchor=CENTER)
782
783pupilquiz = Button(menu_frame, text = "Quiz", command = pupilquiz,bg='#f8f8ff',fg='#1874CD',font = ("Courier",20,"bold"),width=30)
784pupilquiz.place(x=500,rely=0.7,anchor=CENTER)
785
786menu_help_button = Button(menu_frame, text = "Help", command = menu_help,bg='#f8f8ff',fg='#1874CD',font = ("Courier",20,"bold"),width=15)
787menu_help_button.place(x=620,rely=0.8,anchor=CENTER)
788
789menu_back_button = Button(menu_frame, text = "Back", command = back_button_to_login,bg='#f8f8ff',fg='#1874CD',font = ("Courier",20,"bold"),width=15)
790menu_back_button.place(x=380,rely=0.8,anchor=CENTER)
791
792#------------------------------------------------------------------------------------------
793#------------------------------------------------------------------------------------------
794#these are the variables that i will use for each component
795firstname = StringVar()
796surname = StringVar()
797email = StringVar()
798emailaddress = StringVar()
799
800gender_choice = IntVar()
801mobile = StringVar()
802
803
804lblHeading = Label(pupilentry_frame, text = "Add Pupil",bg='white',fg='#1874CD', font = ("Courier",72,"bold"))
805lblHeading .place(x=500,rely=0.1,anchor=CENTER)
806
807
808lblFirstName = Label(pupilentry_frame, text = "First Name:",bg='white',fg='#1874CD',font = ("Courier",28,"bold"))
809lblFirstName.place(x=375,rely=0.2,anchor=CENTER )
810
811entryfirstname = Entry(pupilentry_frame, textvariable = firstname,bg='#f8f8ff',font = ("Courier",20,"bold"),width=15)
812entryfirstname.place(x=625,rely=0.2,anchor=CENTER )
813
814lblSurName = Label(pupilentry_frame, text = "Surname:",bg='white',fg='#1874CD',font = ("Courier",28,"bold"))
815lblSurName.place(x=375,rely=0.29,anchor=CENTER )
816
817entryfirstname = Entry(pupilentry_frame, textvariable = surname,bg='#f8f8ff',font = ("Courier",20,"bold"),width=15)
818entryfirstname.place(x=625,rely=0.29,anchor=CENTER )
819
820#Radio buttons are here
821lblGender = Label(pupilentry_frame, text = "Gender:",bg='white',fg='#1874CD',font = ("Courier",28,"bold"))
822lblGender.place(x=375,rely=0.39,anchor=CENTER )
823
824gender_radiobutton1 = Radiobutton(pupilentry_frame, text = "Male", variable = gender_choice, value = 1,fg='#1874CD',bg='white',font = ("Courier",20,"bold"),width=5)
825gender_radiobutton1.place(x=550,rely=0.39,anchor=CENTER )
826
827gender_radiobutton2= Radiobutton(pupilentry_frame, text = "Female", variable = gender_choice, value = 2,fg='#1874CD',bg='white',font = ("Courier",20,"bold"),width=7)
828gender_radiobutton2.place(x=675,rely=0.39,anchor=CENTER )
829
830
831#this is for the label of email
832lblemail = Label(pupilentry_frame, text = "Email:",fg='#1874CD',bg='white',font = ("Courier",28,"bold"))
833lblemail.place(x=375,rely=0.49,anchor=CENTER )
834#this is for the entry box
835entryemail = Entry(pupilentry_frame, textvariable = email, bg='#f8f8ff',font = ("Courier",20,"bold"),width=8)
836entryemail.place(x=575,rely=0.49,anchor=CENTER )
837#here is the drop box list
838list1 = ["@gmail.com", "@hotmail.com", "@icloud.com", "@yahoo.com", "@c2kni.net"]
839droplist = OptionMenu(pupilentry_frame,emailaddress,*list1)
840droplist.config( bg='#f8f8ff',font = ("Courier",10,"bold"),width=10,height=1,fg='#1874CD')
841emailaddress.set("@gmail.com")
842droplist.place(x=710,rely=0.49,anchor=CENTER )
843
844
845lblMobile = Label(pupilentry_frame, text = "Mobile: +44",bg='white',fg='#1874CD',font = ("Courier",28,"bold"))
846lblMobile.place(x=375,rely=0.59,anchor=CENTER )
847
848entryMobile = Entry(pupilentry_frame, textvariable = mobile,bg='#f8f8ff',font = ("Courier",20,"bold"),width=15)
849entryMobile.place(x=625,rely=0.59,anchor=CENTER )
850
851lblAge = Label(pupilentry_frame, text = "Age:",bg='white',fg='#1874CD',font = ("Courier",28,"bold"))
852lblAge.place(x=375,rely=0.69,anchor=CENTER )
853
854age_spin=Spinbox( pupilentry_frame,from_ = 11 ,to =18,width =8,font=("Courier",28))
855age_spin.place(x=625,rely=0.69,anchor=CENTER )
856
857
858#here's the code for all the buttons
859
860submit_button = Button(pupilentry_frame, text = "Add", command = add_pupil_details,bg='#f8f8ff',fg='#1874CD',font = ("Courier",28,"bold"),width=5)
861submit_button.place(relx=0.74,rely=0.8,anchor=CENTER )
862
863back_button = Button(pupilentry_frame, text = "Back",command=back_addp,bg='#f8f8ff',fg='#1874CD',font = ("Courier",28,"bold"),width=5)
864back_button.place(x=325,rely=0.8,anchor=CENTER )
865
866help_button = Button(pupilentry_frame, text = "Help",command=help_addp,bg='#f8f8ff',fg='#1874CD',font = ("Courier",28,"bold"),width=5)
867help_button.place(x=465,rely=0.8,anchor=CENTER )
868
869addpupil_clear_button = Button(pupilentry_frame, text = "Clear",bg='#f8f8ff',fg='#1874CD', command = AddP_clear_button,font = ("Courier",28,"bold"),width=5)
870addpupil_clear_button.place(relx=0.6,rely=0.8,anchor=CENTER )
871
872
873#------------------------------------------------------------------------------------------
874#------------------------------------------------------------------------------------------
875id_pup=StringVar()
876slope_1_time=StringVar()
877slope_2_time=StringVar()
878slope_3_time=StringVar()
879slope_4_time=StringVar()
880slope_5_time=StringVar()
881
882lblHeadingfindtime = Label(ski_slopes_frame, text = "Find Time",bg='white',fg='#1874CD', font = ("Courier",72,"bold"))
883lblHeadingfindtime.place(x=500,rely=0.1,anchor=CENTER)
884
885id_pup_time_label = Label(ski_slopes_frame, text = "ID:",bg='white',fg='#1874CD',font = ("Courier",28,"bold"))
886id_pup_time_label.place(x=250,rely=0.19,anchor=CENTER)
887
888id_pup_time_entry = Entry(ski_slopes_frame,textvariable = id_pup,bg='#f8f8ff',font = ("Courier",28,"bold"),width=15)
889id_pup_time_entry.place(x=625,rely=0.19,anchor=CENTER)
890
891
892lblslope1 = Label(ski_slopes_frame, text = "Slope time 1:",fg='#1874CD',bg='white',font = ("Courier",28,"bold"))
893lblslope1.place(x=250,rely=0.29,anchor=CENTER)
894
895lblslope2 = Label(ski_slopes_frame, text = "Slope time 2:",fg='#1874CD',bg='white',font = ("Courier",28,"bold"))
896lblslope2.place(x=250,rely=0.39,anchor=CENTER)
897
898lblslope3 = Label(ski_slopes_frame, text = "Slope time 3:",fg='#1874CD',bg='white',font = ("Courier",28,"bold"))
899lblslope3.place(x=250,rely=0.49,anchor=CENTER)
900
901lblslope4 = Label(ski_slopes_frame, text = "Slope time 4:",fg='#1874CD',bg='white',font = ("Courier",28,"bold"))
902lblslope4.place(x=250,rely=0.59,anchor=CENTER)
903
904
905lblslope5 = Label(ski_slopes_frame, text = "Slope time 5:",fg='#1874CD',bg='white',font = ("Courier",28,"bold"))
906lblslope5.place(x=250,rely=0.69,anchor=CENTER)
907
908slope_time_1_entry = Entry(ski_slopes_frame,textvariable = slope_1_time,bg='#f8f8ff',font = ("Courier",28,"bold"),width=15)
909slope_time_1_entry.place(x=625,rely=0.29,anchor=CENTER)
910
911
912slope_time_2_entry = Entry(ski_slopes_frame,textvariable = slope_2_time,bg='#f8f8ff',font = ("Courier",28,"bold"),width=15)
913slope_time_2_entry.place(x=625,rely=0.39,anchor=CENTER)
914
915slope_time_3_entry = Entry(ski_slopes_frame,textvariable = slope_3_time,bg='#f8f8ff',font = ("Courier",28,"bold"),width=15)
916slope_time_3_entry.place(x=625,rely=0.49,anchor=CENTER)
917
918slope_time_4_entry = Entry(ski_slopes_frame,textvariable = slope_4_time,bg='#f8f8ff',font = ("Courier",28,"bold"),width=15)
919slope_time_4_entry.place(x=625,rely=0.59,anchor=CENTER)
920
921slope_time_5_entry = Entry(ski_slopes_frame,textvariable = slope_5_time,bg='#f8f8ff',font = ("Courier",28,"bold"),width=15)
922slope_time_5_entry.place(x=625,rely=0.69,anchor=CENTER)
923
924
925#Buttons
926time_find_button = Button(ski_slopes_frame, text = "Find",command = find_student,fg='#1874CD',bg='#f8f8ff',font = ("Courier",28,"bold"),width=12)
927time_find_button.place(x=650,rely=0.79,anchor=CENTER)
928
929time_back_buttton = Button(ski_slopes_frame, text = "Back",command = back,bg='#f8f8ff',fg='#1874CD',font = ("Courier",28,"bold"),width=7)
930time_back_buttton.place(x=200,rely=0.79,anchor=CENTER )
931
932time_help_button = Button(ski_slopes_frame, text = "Help",command = findp_help,bg='#f8f8ff',fg='#1874CD',font = ("Courier",28,"bold"),width=7)
933time_help_button.place(x=400,rely=0.79,anchor=CENTER )
934
935#------------------------------------------------------------------------------------------
936#------------------------------------------------------------------------------------------
937#the Gui components
938
939#row 0 heading #
940time_lblheading = Label(SkitimesTV, text = "Times Report",bg='white',fg='#1874CD', font = ("Courier",72,"bold"))
941time_lblheading.place(x=500,rely=0.1,anchor=CENTER)
942
943time_find_button = Button(SkitimesTV, text = "Report By Ski Times",command = display_ski_times,fg='#1874CD',bg='#f8f8ff',font = ("Courier",18,"bold"),width=50)
944time_find_button.place(relx=0.5,rely=0.2,anchor=CENTER)
945
946
947TimesTV = ttk.Treeview(SkitimesTV,height = 15, columns = ("Firstname", "Average Time"))
948TimesTV.place(relx=0.2,rely=0.3)
949
950time_scrollBar = Scrollbar(SkitimesTV, orient = 'vertical', command = TimesTV.yview)
951time_scrollBar.place(relx=0.8,rely=0.3,height=325)
952
953TimesTV.configure(xscrollcommand=time_scrollBar.set)
954
955TimesTV.heading("#0", text = "Pupil ID")
956TimesTV.heading("#1", text = "Firstname")
957TimesTV.heading("#2", text = "Average Time")
958
959#Buttons
960
961Rtime_back_buttton = Button(SkitimesTV, text = "Back",command = back,bg='#f8f8ff',fg='#1874CD',font = ("Courier",28,"bold"),width=7)
962Rtime_back_buttton.place(relx=0.4,rely=0.9,anchor=CENTER )
963
964Rtime_help_button = Button(SkitimesTV, text = "Help",command = help_repT,bg='#f8f8ff',fg='#1874CD',font = ("Courier",28,"bold"),width=7)
965Rtime_help_button.place(relx=0.6,rely=0.9,anchor=CENTER )
966#------------------------------------------------------------------------------------------
967#------------------------------------------------------------------------------------------
968
969#components for the skill groups
970
971group_type = StringVar()
972Group = StringVar()
973
974group_lblHeading = Label(pupil_groups_frame, text = "Skill Groups",bg='white',fg='#1874CD', font = ("Courier",72,"bold"))
975group_lblHeading.place(x=500,rely=0.1,anchor=CENTER)
976
977find_group_button = Button(pupil_groups_frame, text = "Find group",command = find_skill_group,fg='#1874CD',bg='#f8f8ff',font = ("Courier",18,"bold"),width=50)
978find_group_button.place(relx=0.5,rely=0.2,anchor=CENTER)
979
980
981
982
983label_group= Label(pupil_groups_frame, text = "Choose a Ski group",fg='#1874CD',bg='#f8f8ff',font = ("Courier",18,"bold"))
984label_group.place(relx=0.3,rely=0.3,anchor=CENTER)
985
986
987pupilskillgroupslist = ["Beginner", "Intermediate", "Advanced","All"]
988group_type.set("All")
989droplist = OptionMenu(pupil_groups_frame,group_type,*pupilskillgroupslist)
990droplist.config(width = 15)
991droplist.place(relx=0.6,rely=0.3,anchor=CENTER)
992
993
994hGroupTV = ttk.Treeview(pupil_groups_frame, height = 15, columns = ("First Name", "Last Name", "Group Level"))
995hGroupTV.place(relx=0.1,rely=0.4)
996
997scrollBar = Scrollbar(pupil_groups_frame, orient = 'vertical', command = hGroupTV.yview)
998scrollBar.place(relx=0.9,rely=0.4,height=325)
999
1000hGroupTV.configure(yscrollcommand=scrollBar.set)
1001
1002hGroupTV.heading('#0', text = "Pupil ID")
1003hGroupTV.heading('#1', text = "First Name")
1004hGroupTV.heading('#2', text = "Last Name")
1005hGroupTV.heading('#3', text = "Group Level")
1006
1007#buttons
1008
1009Groups_back_buttton = Button(pupil_groups_frame, text = "Back",command = back,bg='#f8f8ff',fg='#1874CD',font = ("Courier",28,"bold"),width=7)
1010Groups_back_buttton.place(relx=0.4,rely=0.92,anchor=CENTER )
1011
1012Groups_help_button = Button(pupil_groups_frame, text = "Help",command = help_Skigroups,bg='#f8f8ff',fg='#1874CD',font = ("Courier",28,"bold"),width=7)
1013Groups_help_button.place(relx=0.6,rely=0.92,anchor=CENTER )
1014
1015#------------------------------------------------------------------------------------------
1016#------------------------------------------------------------------------------------------
1017#Here are the variables used to capture data entered in the various frames
1018#Quiz 1 Frame
1019quiz1_studentid = StringVar()
1020
1021#this is the StringVar that will contain the current score, i will refer to this variable as i am using multiple frames
1022current_score = StringVar()
1023
1024#these are the variables for the dropdown questions
1025ski_walk_question = StringVar()
1026ski_equip_question = StringVar()
1027ski_time_question = StringVar()
1028ski_body_question = StringVar()
1029ski_binding_question = StringVar()
1030ski_condition_question = StringVar()
1031ski_occur_question = StringVar()
1032ski_helmet_question = StringVar()
1033ski_leave_question = StringVar()
1034ski_injury_question = StringVar()
1035
1036
1037#components for the Quiz
1038#this code is for the initail menu frame of the quiz
1039menulabel1 = Label(pupil_safety_quiz, text = "Ski Safety Quiz", bg = "#f8f8ff",fg="#1874CD", font = ("Courier",40, "bold"))
1040menulabel1.place(relx=0.5,rely=0.1,anchor=CENTER)
1041
1042menu_start_button = Button(pupil_safety_quiz, text = "Click to Begin",command = start_quiz, bg = "#f8f8ff",fg="#1874CD", font = ("Courier",32,"bold"))
1043menu_start_button.place(relx=0.5,rely=0.3,anchor=CENTER)
1044
1045menu_help_button = Button(pupil_safety_quiz, text = "Help", command = help_menu, bg = '#f8f8ff',fg = '#1874CD', font = ("Courier",24,"bold"))
1046menu_help_button.place(relx= 0.7, rely=0.5, anchor=CENTER)
1047
1048Quiz_back_buttton1 = Button(pupil_safety_quiz, text = "Back",command = back,bg='#f8f8ff',fg='#1874CD',font = ("Courier",24,"bold"))
1049Quiz_back_buttton1.place(relx=0.3,rely=0.5,anchor=CENTER )
1050
1051canvas = Canvas(pupil_safety_quiz, width = 300, height = 254, bg = "white")
1052canvas.place(relx=0.46,rely=0.75,anchor=CENTER)
1053my_image = PhotoImage(file = "Ski-safe.png")
1054canvas.create_image(0,0, anchor = NW, image = my_image)
1055canvas.my_image = my_image
1056
1057results_buttton = Button(pupil_safety_quiz, text = "Results",command = Quiz_Results,bg='#f8f8ff',fg='#1874CD',font = ("Courier",24,"bold"))
1058results_buttton.place(relx=0.5,rely=0.5,anchor=CENTER )
1059#-----------------------------------------------------------------------------------------------------------
1060#In this section of the code I am going to add all the components required to create the Quiz 1 Frame (everything but the questions)
1061quiz1_intro_label = Label(Question_frame1, text = "General Knowledge Quiz",bg = "#f8f8ff",fg="#1874CD", font = ('Courier',30, 'bold'))
1062quiz1_intro_label.place(relx=0.5,rely=0.1,anchor=CENTER)
1063
1064quiz_studentid_label = Label(Question_frame1, text = "Please enter Student ID: ",bg = "#f8f8ff",fg="#1874CD", font = ('Courier', 20, 'bold'))
1065quiz_studentid_label.place(relx=0.3,rely=0.2,anchor=CENTER)
1066
1067quiz_student_entry = Entry(Question_frame1, textvariable = quiz1_studentid)
1068quiz_student_entry.place(relx=0.6,rely=0.2,anchor=CENTER)
1069
1070quiz1_score_label = Label(Question_frame1, text = "Score: ",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',20,'bold'))
1071quiz1_score_label.place(relx=0.8,rely=0.2,anchor=CENTER)
1072
1073quiz1_score_display_label = Label(Question_frame1, textvariable = current_score,bg = "#f8f8ff",fg="#1874CD", font = ('Courier',20,'bold'))
1074quiz1_score_display_label.place(relx=0.9,rely=0.2,anchor=CENTER)
1075current_score.set("0")
1076
1077quiz_advice_label = Label(Question_frame1, text = "Answer the following questions:",bg = "#f8f8ff",fg="#1874CD", font = ('Courier',20,'bold'))
1078quiz_advice_label.place(relx=0.5,rely=0.3,anchor=CENTER)
1079
1080Quiz1_help_button = Button(Question_frame1, text = "Help", command = help_quiz1, bg = '#f8f8ff',fg = '#1874CD', font = ("Courier",24,"bold"))
1081Quiz1_help_button.place(relx= 0.4, rely=0.9, anchor=CENTER)
1082
1083Next_button = Button(Question_frame1, text = "Next", command = start_quiz2,bg='#f8f8ff',fg='#1874CD',font = ("Courier",24,"bold"))
1084Next_button.place(relx=0.7,rely=0.9,anchor=CENTER)
1085#-----------------------------------------------------------------------------------------------------------------------------------------
1086#components for the first frame of questions (1-5)
1087#Question 1
1088quiz_q1_question = Label(Question_frame1, text = "1) What way should you face when walking up an mountain, while wearing ski boots?",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',12,'bold'))
1089quiz_q1_question.place(relx=0.42,rely=0.4,anchor=CENTER)
1090list1 = ['Forwards', 'Backwards', 'sideways.']
1091
1092droplist = OptionMenu(Question_frame1,ski_walk_question,*list1)
1093droplist.config(width = 15)
1094ski_walk_question.set('Select answer')
1095droplist.place(relx=0.9,rely=0.4,anchor=CENTER)
1096#-----------------------------------------------------------------------------------------------------------------------------------------------------
1097#Question 2
1098quiz_q2_question = Label(Question_frame1, text = "2) What the most important piece of equipment for skiing?",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',12,'bold'))
1099quiz_q2_question.place(relx=0.30,rely=0.5,anchor=CENTER)
1100list2 = ['Gloves', 'Socks', 'Ski boots.']
1101
1102droplist = OptionMenu(Question_frame1,ski_equip_question,*list2)
1103droplist.config(width = 15)
1104ski_equip_question.set('Select answer')
1105droplist.place(relx=0.9,rely=0.5,anchor=CENTER)
1106#----------------------------------------------------------------------------------------------------------------------------------------------------------
1107#Question 3
1108quiz_q3_question = Label(Question_frame1, text = "3) What time of day is it most dangerous to ski at?",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',12,'bold'))
1109quiz_q3_question.place(relx=0.27,rely=0.6,anchor=CENTER)
1110list3 = ['Morning', 'Afternoon.', 'Evening']
1111
1112droplist = OptionMenu(Question_frame1,ski_time_question,*list3)
1113droplist.config(width = 15)
1114ski_time_question.set('Select answer')
1115droplist.place(relx=0.9,rely=0.6,anchor=CENTER)
1116#-------------------------------------------------------------------------------------------------------------------------------------------------------------
1117#Question 4
1118quiz_q4_question = Label(Question_frame1, text = "4) What is the most vanerable part of your body while skiing?",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',12,'bold'))
1119quiz_q4_question.place(relx=0.32,rely=0.7,anchor=CENTER)
1120list4 = ['Hands', 'Knees.', 'Ankles']
1121
1122droplist = OptionMenu(Question_frame1,ski_body_question,*list4)
1123droplist.config(width = 15)
1124ski_body_question.set('Select answer')
1125droplist.place(relx=0.9,rely=0.7,anchor=CENTER)
1126#------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1127#Question 5
1128quiz_q5_question = Label(Question_frame1, text = "5) What common problems do skiers have with their bindings?",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',12,'bold'))
1129quiz_q5_question.place(relx=0.31,rely=0.8,anchor=CENTER)
1130list5 = ['Its tension.', 'Breaking unexpectedly', 'They jam']
1131
1132droplist = OptionMenu(Question_frame1,ski_binding_question,*list5)
1133droplist.config(width = 15)
1134ski_binding_question.set('Select answer')
1135droplist.place(relx=0.9,rely=0.8,anchor=CENTER)
1136
1137#-------------------------------------------------------------------------------------------------------------------------------------------------------------------
1138#set up for the second frame of questions(6-10)
1139quiz2_intro_label = Label(Question_frame2, text = "General Knowledge Quiz Part 2",bg = "#f8f8ff",fg="#1874CD", font = ('Courier',30, 'bold'))
1140quiz2_intro_label.place(relx=0.5,rely=0.1,anchor=CENTER)
1141
1142quiz2_score_label = Label(Question_frame2, text = "Score: ",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',20,'bold'))
1143quiz2_score_label.place(relx=0.5,rely=0.2,anchor=CENTER)
1144
1145quiz2_score_display_label = Label(Question_frame2, textvariable = current_score,bg = "#f8f8ff",fg="#1874CD", font = ('Courier',20,'bold'))
1146quiz2_score_display_label.place(relx=0.55,rely=0.2,anchor=CENTER)
1147current_score.set("0")
1148
1149quiz2_advice_label = Label(Question_frame2, text = "Answer the following questions:",bg = "#f8f8ff",fg="#1874CD", font = ('Courier',20,'bold'))
1150quiz2_advice_label.place(relx=0.5,rely=0.3,anchor=CENTER)
1151
1152Quiz2_help_button = Button(Question_frame2, text = "Help", command = help_quiz1, bg = '#f8f8ff',fg = '#1874CD', font = ("Courier",24,"bold"))
1153Quiz2_help_button.place(relx= 0.3, rely=0.9, anchor=CENTER)
1154
1155submit_button = Button(Question_frame2, text = "Submit", command = submit_quiz1,bg='#f8f8ff',fg='#1874CD',font = ("Courier",24,"bold")) #need to make functional
1156submit_button.place(relx=0.7,rely=0.9,anchor=CENTER)
1157#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1158#Question 6
1159quiz_q6_question = Label(Question_frame2, text = "6) What non-injury condition are skiers most vunerable to?",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',12,'bold'))
1160quiz_q6_question.place(relx=0.42,rely=0.4,anchor=CENTER)
1161list6 = ['Vertigo', 'Dehydration.', 'Frostbite']
1162
1163droplist = OptionMenu(Question_frame2,ski_condition_question,*list6)
1164droplist.config(width = 15)
1165ski_condition_question.set('Select answer')
1166droplist.place(relx=0.9,rely=0.4,anchor=CENTER)
1167#-----------------------------------------------------------------------------------------------------------------------------------------------------------------
1168#Question 7
1169quiz_q7_question = Label(Question_frame2, text = "7) When do many skiing injuries occur?",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',12,'bold'))
1170quiz_q7_question.place(relx=0.32,rely=0.5,anchor=CENTER)
1171list7 = ['After heavy snowfall', 'Ones first time skiing.', 'During jumps']
1172
1173droplist = OptionMenu(Question_frame2,ski_occur_question,*list7)
1174droplist.config(width = 15)
1175ski_occur_question.set('Select answer')
1176droplist.place(relx=0.9,rely=0.5,anchor=CENTER)
1177#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1178#Question 8
1179quiz_q8_question = Label(Question_frame2, text = "8) When should you be wearing your ski helmet?",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',12,'bold'))
1180quiz_q8_question.place(relx=0.36,rely=0.6,anchor=CENTER)
1181list8 = ['Always.', 'When learing', 'Going down advanced slopes']
1182
1183droplist = OptionMenu(Question_frame2,ski_helmet_question,*list8)
1184droplist.config(width = 15)
1185ski_helmet_question.set('Select answer')
1186droplist.place(relx=0.9,rely=0.6,anchor=CENTER)
1187#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1188#Question 9
1189quiz_q9_question = Label(Question_frame2, text = "9) Should you leave you instructor while skiing?",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',12,'bold'))
1190quiz_q9_question.place(relx=0.37,rely=0.7,anchor=CENTER)
1191list9 = ['Yes', 'No.']
1192
1193droplist = OptionMenu(Question_frame2,ski_leave_question,*list9)
1194droplist.config(width = 15)
1195ski_leave_question.set('Select answer')
1196droplist.place(relx=0.9,rely=0.7,anchor=CENTER)
1197#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1198#Question 10
1199quiz_q10_question = Label(Question_frame2, text = "10) What should you do if you get injured while skiing?",bg = "#f8f8ff",fg="#1874CD",font = ('Courier',12,'bold'))
1200quiz_q10_question.place(relx=0.4,rely=0.8,anchor=CENTER)
1201list10 = ['Stop and tell the instructor.', 'Keep going', 'Dont tell anyone']
1202
1203droplist = OptionMenu(Question_frame2,ski_injury_question,*list10)
1204droplist.config(width = 15)
1205ski_injury_question.set('Select answer')
1206droplist.place(relx=0.9,rely=0.8,anchor=CENTER)
1207
1208
1209
1210
1211#---------------------------------------------------------------------------------------------------------------------------
1212#components for the quiz results
1213
1214group_type = StringVar()
1215
1216Quiz_Results_lblheading = Label(pupil_results, text = "Quiz Results Report",bg='white',fg='#1874CD', font = ("Courier",55,"bold"))
1217Quiz_Results_lblheading.place(relx=0.5,rely=0.1,anchor=CENTER)
1218
1219find_group_button = Button(pupil_results, text = "Show Results",command = find_skill_group,fg='#1874CD',bg='#f8f8ff',font = ("Courier",18,"bold"),width=50)
1220find_group_button.place(relx=0.5,rely=0.2,anchor=CENTER)
1221
1222label_group= Label(pupil_results, text = "How would like the data to be shown? ",fg='#1874CD',bg='#f8f8ff',font = ("Courier",18,"bold")) #results code not working yet just components in
1223label_group.place(relx=0.3,rely=0.3,anchor=CENTER)
1224
1225pupilskillgroupslist = ["Highest to Lowest", "Lowest to Highest"]# #you will change GroupTV to ResultsTV
1226group_type.set("Highest to Lowest")
1227droplist = OptionMenu(pupil_results,group_type,*pupilskillgroupslist)#
1228droplist.config(width = 15)
1229
1230droplist.place(relx=0.7,rely=0.3,anchor=CENTER)
1231
1232GroupTV = ttk.Treeview(pupil_results, height = 15, columns = ("First Name", "Last Name", "Quiz Results"))
1233GroupTV.place(relx=0.1,rely=0.4)
1234
1235scrollBar = Scrollbar(pupil_results, orient = 'vertical', command = GroupTV.yview)
1236scrollBar.place(relx=0.9,rely=0.4,height=325)
1237
1238GroupTV.configure(yscrollcommand=scrollBar.set)
1239
1240GroupTV.heading('#0', text = "Pupil ID")
1241GroupTV.heading('#1', text = "First Name")
1242GroupTV.heading('#2', text = "Last Name")
1243GroupTV.heading('#3', text = "Quiz Results")
1244
1245#buttons----------------------------------------------------------------------------------------------------------
1246
1247QuizR_back_buttton1 = Button(pupil_results, text = "Back",command = back,bg='#f8f8ff',fg='#1874CD',font = ("Courier",24,"bold"))
1248QuizR_back_buttton1.place(relx=0.2,rely=0.9,anchor=CENTER )
1249
1250QuizR_help_button = Button(pupil_results, text = "Help",command = help_QResults,bg='#f8f8ff',fg='#1874CD',font = ("Courier",24,"bold"))
1251QuizR_help_button.place(relx=0.8,rely=0.9,anchor=CENTER )
1252
1253#-------------------------------------------------------------------------------------------------------------------------------
1254#components for AGES of the pupils report
1255
1256Age_lblheading = Label(age_report_frame, text = "Pupil Ages Report",bg='white',fg='#1874CD', font = ("Courier",68,"bold"))
1257Age_lblheading.place(x=500,rely=0.1,anchor=CENTER)
1258
1259Age_find_button = Button(age_report_frame, text = "Ages of the Pupils",command = display_ski_times,fg='#1874CD',bg='#f8f8ff',font = ("Courier",18,"bold"),width=50)
1260Age_find_button.place(relx=0.5,rely=0.25,anchor=CENTER)
1261
1262
1263AgesTV = ttk.Treeview(age_report_frame,height = 15, columns = ("Firstname", "Average Time"))
1264AgesTV.place(relx=0.2,rely=0.3)
1265
1266Age_scrollBar = Scrollbar(age_report_frame, orient = 'vertical', command = TimesTV.yview)
1267Age_scrollBar.place(relx=0.8,rely=0.3,height=325)
1268
1269AgesTV.configure(xscrollcommand=time_scrollBar.set)
1270
1271AgesTV.heading("#0", text = "Pupil ID")
1272AgesTV.heading("#1", text = "Firstname")
1273AgesTV.heading("#2", text = "Age")
1274
1275#Buttons
1276
1277Ages_back_buttton = Button(age_report_frame, text = "Back",command = back,bg='#f8f8ff',fg='#1874CD',font = ("Courier",28,"bold"),width=7)
1278Ages_back_buttton.place(relx=0.4,rely=0.9,anchor=CENTER )
1279
1280Ages_help_button = Button(age_report_frame, text = "Help",command = help_AgesRep,bg='#f8f8ff',fg='#1874CD',font = ("Courier",28,"bold"),width=7)
1281Ages_help_button.place(relx=0.6,rely=0.9,anchor=CENTER )
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313#here we call the function raise_frame to bring the log in frame into view
1314raise_frame(login_frame)
1315#here is where the magic happens
1316root.mainloop()