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
| from tkinter import *
from tkinter.constants import END
quiz_window = Tk()
quiz_window.title("Quiz")
quiz_window.geometry("500x600")
#Question 1
def question1_check():
if entry_question_1.get() == answer_question_1:
label_right_answer_q1 = Label(quiz_window, text="Correct",font=("Arial",15), fg="green")
label_right_answer_q1.grid()
entry_question_1.delete(0, END)
else:
label_wrong_answer_q1 = Label(quiz_window, text="Incorrect",font=("Arial",15), fg="red")
label_wrong_answer_q1.grid()
entry_question_1.delete(0, END)
label_question_1 = Label(quiz_window, text="Quelle est la capitale de la France ?", font=("Helvetica", 20), fg="blue")
answer_question_1 = "Paris"
entry_question_1 = Entry(quiz_window)
button_check = Button(quiz_window, text="Valider", command=question1_check)
label_question_1.grid(padx=40)
entry_question_1.grid()
button_check.grid(pady=20)
quiz_window.mainloop() |
Partager