This script will let you make a test with tkinter
import tkinter as tk from time import sleep quest = [ #1 ("""I Paesi che negli ultimi anni hanno registrato elevati aumenti di spese per il turismo outgoing sono la Cina e la Russia.""","v"), #2 (""" Secondo l’OMT un visitatore è considerato un turista se effettua almeno tre pernottamenti nella località visitata. ""","f"), #3 ("""Nel 2014 il continente più visitato dai turisti di tutto il mondo è stato l’Asia.""", "f"), #4 ("""Negli ultimi anni i flussi turistici internazionali sono cresciuti a un tasso medio del 4,5% l’anno. ""","v") ] numdom = len(quest) score = 0 num = 0 def d1(): global num, score, entry if num == numdom: text.pack_forget() entry.pack_forget() score = int(score // num) * 100 button['text'] = f"Score {score}%\n Click to Close this window" button['command'] = game_over button.pack() return if num == 0: answer_widget() text['height'] = 7 text['bg'] = 'cyan' text['width'] = 80 text.delete("1.0",tk.END) text.insert("1.0",quest[num][0] + "[v][f]") button.pack_forget() num+=1 def game_over(): root.destroy() def answer_widget(): global entry entry = tk.Entry(root, textvariable=solution, bg="yellow", font="Arial 20") entry.pack() entry.bind("<Return>", lambda x: check()) entry.focus() def check(): global n, score if solution.get() == quest[num-1][1]: text.insert(tk.END, "Right") score+=1 else: text.insert(tk.END, "Wrong") solution.set("") d1() root = tk.Tk() label = tk.Label(root, text = """Test""", bg="coral", font="Arial 48") label.pack() rules = """Answer to the Following questions Click on the button below to start You will see a question Write your answer and press Enter """ text = tk.Text(root, height=12,font="Arial 20") text.insert("1.0", rules) text.pack() button = tk.Button(root, text="Click To Start", bg="black", fg="white", command=d1, font="Arial 20") button.pack() solution = tk.StringVar() root.mainloop()
Subscribe to the newsletter for updates
Tkinter templates
My youtube channel
Twitter: @pythonprogrammi - python_pygame