-
Notifications
You must be signed in to change notification settings - Fork 0
/
Iteration 1 - Modification 2
70 lines (51 loc) · 2.36 KB
/
Iteration 1 - Modification 2
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
from tkinter import *
from tkinter import ttk
class Advanced_English_Quiz:
def __init__(self, parent):
Name = None
Age = None
"""Widgets for Frame 1"""
self.Home = Frame(parent)
self.Home.grid(row=0, column=0)
self.TitleLabel = Label(self.Home, bg = "Green", fg ="white", width = 80, padx=100, pady=100, height=2,
text = "Advanced English Quiz", font = ("Times", "18", "bold italic"))
self.TitleLabel.grid(row=0, columnspan=4)
self.NameLabel = Label(self.Home, bg = "white", fg = "black", padx = 10, pady = 20,
text = "Enter Name: ", font = ("Times", "14", "bold"))
self.NameLabel.grid(row=4, column=0)
self.EnterName = Entry(self.Home, width=40)
self.EnterName.grid(row=4, column=1)
self.AgeLabel = Label(self.Home, bg = "white", fg = "black", padx = 10, pady = 20,
text = "Enter Age: ", font = ("Times", "14", "bold"))
self.AgeLabel.grid(row=8, column=0)
self.EnterAge = Entry(self.Home, width=40)
self.EnterAge.grid(row=8, column=1)
self.nextbutton = ttk.Button(self.Home, text="Next", command=self.show_frame)
self.nextbutton.grid(row=10, column=1)
def show_frame(self):
global Name
age = self.EnterAge.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)
if __name__ == "__main__":
root = Tk()
frames = Advanced_English_Quiz(root)
root.geometry("400x350")
root.title("English Rich Quiz")
root.mainloop()