-
Notifications
You must be signed in to change notification settings - Fork 0
/
Iteration 2 - Modification 1
134 lines (106 loc) · 6.11 KB
/
Iteration 2 - Modification 1
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
from tkinter import *
from tkinter import ttk
class Advanced_English_Quiz:
def __init__(self, parent):
Name = ""
Age = 0
"""Widgets for Frame 1"""
self.home = Frame(parent)
self.home.grid(row=0, column=0)
self.title_label = Label(self.home, bg = "Green", fg ="white", width = 105, padx=100, pady=100, height=2,
text = "Advanced English Quiz", font = ("Times", "24", "bold italic"))
self.title_label.grid(row=0, columnspan=3)
self.name_label = Label(self.home, bg = "white", fg = "black", padx = 10, pady = 20,
text = "Enter Name: ", font = ("Times", "14", "bold"))
self.name_label.grid(row=4, column=0)
self.enter_name = Entry(self.home, width=40)
self.enter_name.grid(row=4, column= 1)
self.age_label = Label(self.home, bg = "white", fg = "black", padx = 10, pady = 20,
text = "Enter Age: ", font = ("Times", "14", "bold"))
self.age_label.grid(row=8, column=0)
self.enter_age = Entry(self.home, width=40)
self.enter_age.grid(row=8, column=1)
self.next_button = ttk.Button(self.home, text="Next", command=lambda: [self.show_frame(), self.show_english()])
self.next_button.grid(row=20, column=2)
self.difficulty = Label(self.home, bg = "white", fg = "black", padx = 10, pady = 20,
text = "Choose difficulty: ", font = ("Times", "14", "bold"))
self.difficulty.grid(row=12, column=0, columnspan=1)
self.difficulty = ["English", "History", "Geography"]
self.diff_level = StringVar()
self.diff_level.set(0)
self.diff_buttons = []
for a in range(len(self.difficulty)):
self.difficulty_buttons = Radiobutton(self.home, fg = "black", text=self.difficulty[a], width = 10, padx=10, pady=20,
height=2, value=a, font = ("Times", "14", "bold"))
self.difficulty_buttons.grid(row=a + 12, column=1, sticky=NSEW)
"""Widgets for Frame 2"""
#Dont put grid when making a new frame in the def init, put it in a separate function and call that function with a button
self.english = Frame(parent)
self.english_label = Label(self.english, fg = "white", bg="green", width = 125, padx=100, pady=100,
height=1 ,text = "English Questions", font = ("Times", "20", "bold"))
self.english_label.grid(columnspan=3, row = 0)
self.check_button = ttk.Button(self.english_questions, text='Home', command=self.show_home, width=30)
self.english_questions
"""Widgets for Frame 3"""
# Dont put grid when making a new frame in the def init, put it in a separate function and call that function with a button
self.history = Frame(parent)
self.history_label = Label(self.english, fg = "white", bg="green", width = 125, padx=100, pady=100,
height=1 ,text = "English Questions", font = ("Times", "20", "bold"))
self.history_label.grid(columnspan=3, row = 0)
self.check_button = ttk.Button(self.history_questions, text='Home', command=self.show_home, width=30)
self.history_questions
"""Widgets for Frame 4"""
# Dont put grid when making a new frame in the def init, put it in a separate function and call that function with a button
self.geography = Frame(parent)
self.geography_label = Label(self.english, fg = "white", bg="green", width = 125, padx=100, pady=100,
height=1 ,text = "English Questions", font = ("Times", "20", "bold"))
self.geography_label.grid(columnspan=3, row = 0)
self.check_button = ttk.Button(self.geography_questions, text='Home', command=self.show_home, width=30)
self.geography_answer = Entry(self.geography_questions, width=20)
self.geography_answer.grid(row=4, column=2)
self.geography_answer.focus()
self.geography_answer_label = Label(self.geography_questions, text="Answer:", font=("times", "12", "bold"))
self.geography_answer_label.grid(row=4, column=1)
def show_frame(self):
global Name
age = self.enter_age.get()
try:
self.error_label.grid_remove()
except:
pass
try:
Age = int(age)
if Age > 18:
self.error_label = Label(self.home, text="You are not an appropriate age", fg="red",
font=("times", "10", "bold"))
self.error_label.grid(column=3, row=8)
elif Age < 14:
self.error_label = Label(self.home, text="You are not an appropriate age", fg="red",
font=("times", "10", "bold"))
self.error_label.grid(column=3, row=8)
except:
self.error_label = Label(self.home, text="This is an invalid request", fg="red",
font=("times", "10", "bold"))
self.error_label.grid(column=3, row=8)
def show_english(self):
self.home.grid_remove()
self.english.grid()
def show_history(self):
self.home.grid_remove()
self.history.grid()
def show_geography(self):
self.home.grid_remove()
self.geography.grid()
def englishquestions(self):
QuestionsEnglish = ["1. A dove is a symbol of what? ",
"2. The wind is as cold as ice is an example of what technique? ",
"3. In which point of view is this phrase “Harry looked into my eyes with an odd expression”? ",
"4. True or false? Is pretty ugly an oxymoron? ",
"5 Is the following an example of alliteration or assonance: “The rain in Spain stays mainly on the plain" ]
return QuestionsEnglish[self.englishquesno]
if __name__ == "__main__":
root = Tk()
frames = Advanced_English_Quiz(root)
root.geometry("400x350")
root.title("English Rich Quiz")
root.mainloop()