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
| from tkinter import *
nbr_de_question = 4 # je le fixe, sans possibiliter de le changer
fen1=Tk()
can1=Canvas(fen1,width=500, height=500,bg='white')
can1.pack()
bout = []
te = []
for i in range(nbr_de_question):
te.append("reponse type "+str(i))
def fonction(a):
texte=Label(text= te[a] )
texte.place(x= 100 ,y= a * 40+55)
def fonction0():
fonction(0)
def fonction1():
fonction(1)
def fonction2():
fonction(2)
def fonction3():
fonction(3)
bout0 = Button(text='valider',command= fonction0 )
bout0.place(x= 10 ,y=50)
bout1 = Button(text='valider',command= fonction1 )
bout1.place(x= 10 ,y=90)
bout2 = Button(text='valider',command= fonction2 )
bout2.place(x= 10 ,y=130)
bout3 = Button(text='valider',command= fonction3 )
bout3.place(x= 10 ,y=170)
fen1.mainloop() |
Partager