Python Project for help
from Questions import Questions import json import random from tkinter import * from tkinter import ttk def unpackView(view): view.pack_forget() questionPrompt() class Question: def __init__(self, question, answers, correct_answer): self.question = question self.answers = answers self.correct_answer = correct_answer def check(self, letter, view): global correct_answer if letter == self.correct_answer: label = Label(view, text="Right!", background="ghost white") correct_answer += 2 else: label = Label(view, text="Wrong!", background="ghost white") label.pack() view.after(1000, lambda *args: unpackView(view)) def quiz_window(self, quiz_window): quiz = Frame(quiz_window, width=500, height=100, background="ghost white") Label(quiz, text=self.question, background="ghost white").pack() Button(quiz, text=self.answers[0], width=30, command=lambda *args: self.check("A", quiz)).pack() Button(quiz, text=self.answers[1], width=30, command=lambda *args: self.check("B", quiz)).pack() Button(quiz, text=self.answers[2], width=30, command=lambda *args: self.check("C", quiz)).pack() Button(quiz, text=self.answers[3], width=30, command=lambda *args: self.check("D", quiz)).pack() return quiz def questionPrompt(): global questions, window, index, quiz_button, correct_answer if len(questions) == index + 1: Label(window, text="Point " + str(correct_answer)).pack() return quiz_button.pack_forget() editAdd_button.pack_forget() index += 1 questions[index].quiz_window(window).pack() def editMode(): pass questions = [] file = open("questions.txt", "r") line = file.readline() while line != "": questionString = line answers = [] for i in range(4): answers.append(file.readline()) correctLetter = file.readline() correctLetter = correctLetter[:-1] questions.append(Question(questionString, answers, correctLetter)) line = file.readline() file.close() index = -1 correct_answer = 0 window = Tk() window.geometry('600x400') window.title('Mental Auguish') window.config(bg='ghost white') quiz_button = Button(window, text="Quiz", width=40, command=questionPrompt) quiz_button.pack() editAdd_button = Button(window, text="Edit/Add Questions", width=40) editAdd_button.pack() window.iconbitmap('icon.ico') window.mainloop()