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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| from tkinter import *
from tokenize import String
def create():
for c in racine.winfo_children():
c.destroy()
label3 = Label(racine, text = "L'amie écureuil de Bob l'éponge s'appelle :").grid(sticky="W")
choix1 = Radiobutton(racine, text = "Cindy", variable = v, value = "Cindy").grid(sticky = "w")
choix2 = Radiobutton(racine, text = "Mindy", variable = v, value = "Mindy").grid(sticky = "w")
choix3 = Radiobutton(racine, text = "Sandy", variable = v, value = "Sandy").grid(sticky = "w")
btn2 = Button(racine, text="Question suivante", command = q2).grid()
def q2():
for c in racine.winfo_children():
c.destroy()
label3 = Label(racine, text = "En dormant, Patrick bave plus que Gary :").grid(sticky = "w")
choix1 = Radiobutton(racine, text = "Vrai", variable = m, value = "Vrai").grid(sticky = "w")
choix2 = Radiobutton(racine, text = "Faux", variable = m, value = "faux").grid(sticky = "w")
choix3 = Radiobutton(racine, text = "Match nul", variable = m, value = "matchnul").grid(sticky = "w")
btn3 = Button(racine, text="Question suivante", command = q3).grid()
def q3():
for c in racine.winfo_children():
c.destroy()
label3 = Label(racine, text = "Patrick est une étoile :").grid(sticky = "w")
choix1 = Radiobutton(racine, text = "à 3 branches", variable = p, value = "3").grid(sticky = "w")
choix2 = Radiobutton(racine, text = "à 5 branches", variable = p, value = "5").grid(sticky = "w")
choix3 = Radiobutton(racine, text = "à 6 branches", variable = p, value = "6").grid(sticky = "w")
btn4 = Button(racine, text="Quitter", command = racine.destroy).grid()
racine = Tk()
racine.title("QCM")
racine.minsize( 200, 100)
v = StringVar()
m = StringVar()
p = StringVar()
label1 = Label(racine, text="Bienvenue dans ce QCM pour tester vos connaissances sur Bob L'éponge !!").grid(sticky = "w")
label2 = Label(racine, text="Vous devez cochez la bonne réponse à chaque question").grid(sticky = "W")
btn = Button(racine, text="C'est parti !", command = create)
btn.grid()
cannevasImg = Canvas(racine, width=50, height=63)
photo = PhotoImage(file = "bob.png")
image = cannevasImg.create_image(25, 31.5, image=photo)
cannevasImg.grid(column = 1,row = 1)
# Création d'un cadre pour afficher le score.
cadreScore = Frame(racine, borderwidth=2, relief=GROOVE)
# Affiche le cadreScore.
cadreScore.grid(sticky="E", padx=10, pady=10)
# Affiche le titre du cadreScore.
Label(cadreScore, text="Score :").grid(padx=10, pady=10)
# Création d'un cadre dans le "cadreScore" pour Afficher le nombre de bonne réponse.
cadreVrai = Frame(cadreScore, bg="white", borderwidth=2, relief=GROOVE)
# Affiche le cadreVrai.
cadreVrai.grid(sticky="W", padx=10, pady=10)
# Affiche le titre du cadreVrai.
Label(cadreVrai, text="Bonne réponse(s) :", bg="white").grid(padx=10, pady=10)
cpt1 = 0 # Compteur de bonnes réponses
def inc1():
val = infos['valeur']
v += 1
infos['valeur'] = val
my_bonnrep.itemconfig(text, text=int(val))
infos = {'valeur': cpt1, }
my_bonnrep = Canvas(cadreVrai, width=20, height=20)
my_bonnrep.grid()
text = my_bonnrep.create_text((10, 10), text=cpt1)
# Création d'un cadre dans le "cadreScore" pour afficher le nombre de mauvaise réponse.
cadreFaux = Frame(cadreScore, bg="white", borderwidth=2, relief=GROOVE)
# Affiche le cadreFaux.
cadreFaux.grid(sticky="E", padx=10, pady=10)
# Affiche le titre du cadreFaux.
Label(cadreFaux, text="Mauvaise Réponse(s) :", bg="white").grid(padx=10, pady=10)
cpt2 = 0 # Compteur de mauvaises réponses
def inc2():
val = infos['valeur']
v += 1
infos['valeur'] = val
my_mauvrep.itemconfig(text, text=int(val))
infos = {'valeur': cpt2, }
my_mauvrep = Canvas(cadreFaux, width=20, height=20)
my_mauvrep.grid()
text = my_mauvrep.create_text((10, 10), text=cpt2)
# Création d'un cadre dans le "cadreScore" pour afficher le pourcentage de bonne réponse.
cadreSoit = Frame(cadreScore, bg="white", borderwidth=2, relief=GROOVE)
cpt2 = 0 # Compteur de mauvaises réponses
def inc2():
val = infos['valeur']
v += 1
infos['valeur'] = val
my_mauvrep.itemconfig(text, text=int(val))
infos = {'valeur': cpt2, }
my_mauvrep = Canvas(cadreSoit, width=20, height=20)
my_mauvrep.grid()
text = my_mauvrep.create_text((10, 10), text=cpt2)
racine.mainloop() |