Afficher le score d'un QCM sur tkinter
Phil_1857 Messages postés 1872 Date d'inscription Statut Membre Dernière intervention -
Bonjour, lorsque j'essaye d'afficher le score de mon qcm ( bonne ou mauvaise réponse ) il s'affiche seulement sur la première "fenêtre" ( celle ou je présente le qcm) et je voudrais qu'il s'affiche jusqu'a la fin en comptabilisant les bonne ou mauvaise réponse, voici mon code :
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()
Windows / Chrome 105.0.0.0
- Afficher le score d'un QCM sur tkinter
- Afficher appdata - Guide
- Son score snapchat ne bouge pas ✓ - Forum Snapchat
- Score de malinas ✓ - Forum Excel
- Dans le diaporama à télécharger, les diapositives s’enchaînent automatiquement. combien de temps la diapositive crayon met-elle à s’afficher ? combien de temps reste-t-elle affichée à l’écran ? ✓ - Forum Powerpoint
2 réponses
Ah , ce n'est pas toi ici ?
https://openclassrooms.com/forum/sujet/afficher-le-score-dun-qcm-sur-tkinter
bonjour,
N'as-tu pas posté aussi ceci? https://www.developpez.net/forums/d2138593/autres-langages/python/gui/tkinter/afficher-score-d-qcm-tkinter/
En postant sur plusieurs forums, cela crée un gros gaspillage d'énergie, puisque ceux qui t'aident sur un forum ne voient pas ce que font les autres.
Merci de prévenir quand tu fais cela, pour éviter ce gaspillage.
Bonjour,
j’ai bien re regarde et pourtant je ne trouve aucun forum avec une réponse à mon problème