-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
85 lines (73 loc) · 1.82 KB
/
main.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
from tkinter import *
import quiz_brain
from question_model import Question
from quiz_brain import QuizBrain
from quiz_ui import QuizUI
# Initial UI Setup
initial_window = Tk()
initial_window.title("QuizzMe")
initial_window.config(padx=30, pady=30, bg="#262626")
# Function to go to main page after difficulty is chosen
def next_page(difficulty: str, ):
initial_window.destroy()
# get data
question_data = quiz_brain.get_data(difficulty)
# create banks of questions
questions = []
# fill banks with data from Open Quiz DB
for question in question_data:
question_text = question["question"]
question_answer = question["correct_answer"]
new_question = Question(question_text, question_answer)
questions.append(new_question)
quiz = QuizBrain(questions)
QuizUI(quiz)
title = Label(
text="Welcome to QuizzMe",
padx=20,
pady=20,
bg='#262626',
fg="#d9048e",
font=('Arial', 35)
)
title.grid(column=0, row=0, columnspan=3)
difficulty_label = Label(
text="Choose your difficulty",
padx=20,
pady=40,
bg='#262626',
fg="#d9048e",
font=('Arial', 20)
)
difficulty_label.grid(column=0, row=1, columnspan=3)
easy_button = Button(
text="Easy",
padx=10,
bg="#9b0bd9",
font=('Arial', 15),
highlightthickness=0,
bd=0,
command=lambda: next_page("easy")
)
easy_button.grid(column=0, row=2)
med_button = Button(
text="Medium",
padx=10,
bg="#f2cb05",
font=('Arial', 15),
highlightthickness=0,
bd=0,
command=lambda: next_page("medium")
)
med_button.grid(column=1, row=2)
hard_button = Button(
text="Hard",
padx=10,
bg="#2bc7d9",
font=('Arial', 15),
highlightthickness=0,
bd=0,
command=lambda: next_page("hard")
)
hard_button.grid(column=2, row=2)
initial_window.mainloop()