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
| from tkinter import *
import winsound
import time as t
from random import *
def verif():
global val , bonneRep , fenetreQuestion , mauvaiseRep
val=var.get()
if val == "1":
bonneRep=Label(fenetreQuestion,text="Bonne réponse")
bonneRep.place(x=450,y=150)
print(val)
verifJ1()
#fenetreQuestion.destroy()
elif val == "0":
mauvaiseRep=Label(fenetreQuestion,text="Mauvaise réponse")
mauvaiseRep.place(x=450,y=150)
print(val)
fenetreQuestion.destroy()
def start():
global temps1, temps2, chron , lab , finDuTemps , fenetreQuestion
temps1= t.time()
chrono()
def chrono():
global temps1, temps2, chron , lab
temps2= t.time()
chron=30-temps2+temps1
lab.config(text=int(chron))
if (chron>=0):
fenetreQuestion.after(100,chrono)
else:
finDuTemps=Label(fenetreQuestion,text="Fin du temps imparti")
finDuTemps.place(x=500,y=200)
fenetreQuestion.after(1000,fermerPage)
def fermerPage():
for c in fenetreQuestion.winfo_children():
c.destroy()
fenetreQuestion.destroy()
def questionFacile1(): #La question qui est choisi au hasard
global var , lab , fenetreQuestion , question , reponse1 , reponse2 , reponse3 , bouttonValiderReponse , temps1, temps2, chron , lab , finDuTemps , fenetreQuestion , temps1, temps2, chron , lab
fenetreQuestion=Toplevel()
fenetreQuestion.title("questions")
fenetreQuestion.geometry("1000x500")
question=Label(fenetreQuestion,text="Combien Barbamama et Barbapapa ont-ils d'enfants ? ",fg="pink")
question.place(x=450,y=20)
var=StringVar()
reponse1=Radiobutton(fenetreQuestion,text="7",variable=var, value="1",fg="red")
reponse1.place(x=300,y=75)
reponse2=Radiobutton(fenetreQuestion,text="9",variable=var,value="0",fg="red")
reponse2.place(x=450,y=75)
reponse3=Radiobutton(fenetreQuestion,text="20",variable=var,value="0",fg="red")
reponse3.place(x=600,y=75)
bouttonValiderReponse=Button(fenetreQuestion,text="Valider la réponse",command=verif,fg="green",bg="black")
bouttonValiderReponse.place(x=450,y=110)
lab=Label(fenetreQuestion, text="")
lab.place(x=495,y=10)
start()
fenetreQuestion.mainloop()
def verifJ1(): #Vérification de la réponse du joueur pour le faire avancer puis fermeture de la fenêtre
global posX1 , posY1 , pionJ1 , pointsJ1 , can
val=var.get()
if val == "1":
pointSupp=randint(0,3)
pointsJ1=pointsJ1+pointSupp
#-----------------------Avancer ligne 1------------------------#
if 20 <= posX1 < posTheorique5X1 and posY1 == 20:
posX1=posX1+pas
can.coords(pionJ1,posX1-15,posY1-15,posX1+15,posY1+15)
fenetreQuestion.destroy()
if ValNombreJoueurs == "0": #C'est le déroulement d'un tour de jeu
while posX1 == 20 and posY1 != 440 or posX2 == 60 and posY2 != 440:
labelTour=Label(fen,text="Au tour du joueur 1:",fg="red",bg="black",font="bold 15")
labelTour.place(x=600,y=600)
listeQuestionsFaciles=[questionFacile1]
question=choice(listeQuestionsFaciles)
print(question)
type(question)
question()
verifJ1() |
Partager