#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tkinter import *
from random import randint
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
#mise en place des variables de reponse
def put1(rep):
rep = 1
def put2(rep):
rep = 2
def put3(rep):
rep = 3
# verrification
#ordre : 123213312321
def verify(rep):
questions = ["q1: 1 x 8", "q2: 2 x 8", "q1: 3 x 8", "q2: 4 x 8", "q1: 5 x 8", "q2: 6 x 8", "q1: 7 x 8", "q2: 8 x 8", "q1: 9 x 8", "q2: 10 x 8", "q1: 11 x 8", "q2: 12 x 8"]
reponses = ["8", "16", "24", "36", "40", "48", "56", "64", "72", "80", "88", "96"]
lvl = 1
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
tb1.set(reponses[ranq])
tb2.set(reponses[ran1])
tb3.set(reponses[ran2])
if lvl <= 12:
if lvl == 1:
if rep == 1:
tl.set(questions[ranq])
tb2.set(reponses[ranq])
while ranq == ran1:
ran1 = randint(0, 11)
tb1.set(reponses[rand1])
while ranq == ran2:
ran2 = randint(0, 11)
tb3.set(reponses[rand2])
lvl += 1
else:
f.quit()
elif lvl == 2:
if rep == 2:
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
tl.set(questions[ranq])
tb3.set(reponses[ranq])
while ranq == ran1:
ran1 = randint(0, 11)
tb1.set(reponses[rand1])
while ranq == ran2:
ran2 = randint(0, 11)
tb2.set(reponses[rand2])
lvl += 1
else:
f.quit()
elif lvl == 3:
if rep == 3:
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
tl.set(questions[ranq])
tb2.set(reponses[ranq])
while ranq == ran1:
ran1 = randint(0, 11)
tb1.set(reponses[rand1])
while ranq == ran2:
ran2 = randint(0, 11)
tb3.set(reponses[rand2])
lvl += 1
else:
f.quit()
elif lvl == 4:
if rep == 2:
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
tl.set(questions[ranq])
tb1.set(reponses[ranq])
while ranq == ran1:
ran1 = randint(0, 11)
tb2.set(reponses[rand1])
while ranq == ran2:
ran2 = randint(0, 11)
tb3.set(reponses[rand2])
lvl += 1
else:
f.quit()
elif lvl == 5:
if rep == 1:
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
tl.set(questions[ranq])
tb3.set(reponses[ranq])
while ranq == ran1:
ran1 = randint(0, 11)
tb1.set(reponses[rand1])
while ranq == ran2:
ran2 = randint(0, 11)
tb2.set(reponses[rand2])
lvl += 1
else:
f.quit()
elif lvl == 6:
if rep == 3:
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
tl.set(questions[ranq])
tb3.set(reponses[ranq])
while ranq == ran1:
ran1 = randint(0, 11)
tb1.set(reponses[rand1])
while ranq == ran2:
ran2 = randint(0, 11)
tb2.set(reponses[rand2])
lvl += 1
else:
f.quit()
elif lvl == 7:
if rep == 3:
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
tl.set(questions[ranq])
tb1.set(reponses[ranq])
while ranq == ran1:
ran1 = randint(0, 11)
tb3.set(reponses[rand1])
while ranq == ran2:
ran2 = randint(0, 11)
tb2.set(reponses[rand2])
lvl += 1
else:
f.quit()
elif lvl == 8:
if rep == 1:
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
tl.set(questions[ranq])
tb2.set(reponses[ranq])
while ranq == ran1:
ran1 = randint(0, 11)
tb1.set(reponses[rand1])
while ranq == ran2:
ran2 = randint(0, 11)
tb3.set(reponses[rand2])
lvl += 1
else:
f.quit()
elif lvl == 9:
if rep == 2:
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
tl.set(questions[ranq])
tb3.set(reponses[ranq])
while ranq == ran1:
ran1 = randint(0, 11)
tb1.set(reponses[rand1])
while ranq == ran2:
ran2 = randint(0, 11)
tb2.set(reponses[rand2])
lvl += 1
else:
f.quit()
elif lvl == 10:
if rep == 3:
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
tl.set(questions[ranq])
tb2.set(reponses[ranq])
while ranq == ran1:
ran1 = randint(0, 11)
tb3.set(reponses[rand1])
while ranq == ran2:
ran2 = randint(0, 11)
tb1.set(reponses[rand2])
lvl += 1
else:
f.quit()
elif lvl == 11:
if rep == 2:
ranq = randint(0, 11)
ran1 = randint(0, 11)
ran2 = randint(0, 11)
tl.set(questions[ranq])
tb1.set(reponses[ranq])
while ranq == ran1:
ran1 = randint(0, 11)
tb2.set(reponses[rand1])
while ranq == ran2:
ran2 = randint(0, 11)
tb3.set(reponses[rand2])
lvl += 1
else:
f.quit()
elif lvl == 12:
if rep == 1:
tl.set("")
tb1.set("")
tb2.set("")
tb3.set("")
cons.set("you win")
else:
f.quit()
else:
tl.set("")
tb1.set("")
tb2.set("")
tb3.set("")
cons.set("il est possible que vous ayez ue un problème de compilation ou de programation")
f = Tk()
tb1 = StringVar()
tb2 = StringVar()
tb3 = StringVar()
questions = ["q1: 1 x 8", "q2: 2 x 8", "q1: 3 x 8", "q2: 4 x 8", "q1: 5 x 8", "q2: 6 x 8", "q1: 7 x 8", "q2: 8 x 8", "q1: 9 x 8", "q2: 10 x 8", "q1: 11 x 8", "q2: 12 x 8"]
reponses = ["8", "16", "24", "36", "40", "48", "56", "64", "72", "80", "88", "96"]
reponse = 0
cons = Label(f, text="bonjour appuyer sur un des trois bouttons pour repondre")
cons.pack()
tl = StringVar()
tl.set(questions[ranq])
lq = Label(f, textvariable=tl)
lq.pack()
b1 = Button(f, textvariable = tb1, command=put1(reponse))
b1.pack()
b2 = Button(f, textvariable = tb2, command=put1(reponse))
b2.pack()
b3 = Button(f, textvariable = tb3, command=put1(reponse))
b3.pack()
blan = Button(f, text="verification", command=verify(reponse))
blan.pack()
f.mainloop()
voila mon problème
ça ne fonctionne pas?
je pense mettre la variable rep en global
Afficher la suite