from tkinter import* #crĂ©ation de la fenĂȘtre pour la grille du jeu from random import randint fen1 = Tk() fen1.resizable() fen1.title("Grille du jeu") liste1=[17,93,60,98] liste2=[32,46,72,21] liste4=[24,49,79,25] liste6=[3,56,90,26] liste7=[27,61,94,57] liste8=[15,43,83,78] liste10=[33,52,97,92] liste11=[2,39,80,28] liste14=[20,55,87,59] liste16=[11,53,74,85] liste17=[23,68,81,73] liste18=[29,64,99,82] liste20=[4,37,70,45] liste21=[14,50,89,16] liste22=[6,38,69,31] liste23=[18,44,63,48] liste24=[5,9,19,67] liste25=[58,65,77,95] liste26=[12,30,66,91] liste27=[84,85,13,42] n=4 t=0 t1=randint(0 ,3) bou1=Button(fen1, text=(liste1[t1]), background='white') t2=randint(0 ,3) bou2=Button(fen1, text=(liste2[t2]), background='white') t4=randint(0 ,3) bou4=Button(fen1, text=(liste4[t4]), background='white') t6=randint(0 ,3) bou6=Button(fen1, text=(liste1[t1]), background='white') t7=randint(0 ,3) bou7=Button(fen1, text=(liste7[t7]), background='white') t8=randint(0 ,3) bou8=Button(fen1, text=(liste8[t8]), background='white') t10=randint(0,3) bou10=Button(fen1, text=(liste10[t10]), background='white') t11=randint(0,3) bou11=Button(fen1, text=(liste11[t11]), background='white') t14=randint(0,3) bou14=Button(fen1, text=(liste14[t14]), background='white') t16=randint(0,3) bou16=Button(fen1, text=(liste16[t16]), background='white') t17=randint(0,3) bou17=Button(fen1, text=(liste17[t17]), background='white') t18=randint(0,3) bou18=Button(fen1, text=(liste18[t18]), background='white') t20=randint(0,3) bou20=Button(fen1, text=(liste20[t20]), background='white') t21=randint(0,3) bou21=Button(fen1, text=(liste21[t21]), background='white') t22=randint(0,3) bou22=Button(fen1, text=(liste22[t22]), background='white') t23=randint(0,3) bou23=Button(fen1, text=(liste23[t23]), background='white') t24=randint(0,3) bou24=Button(fen1, text=(liste24[t24]), background='white') t25=randint(0,3) bou25=Button(fen1, text=(liste25[t25]), background='white') t26=randint(0,3) bou26=Button(fen1, text=(liste26[t26]), background='white') t27=randint(0,3) bou27=Button(fen1, text=(liste27[t27]), background='white') bou1['command'] = lambda bou1=bou1: bou1.configure(background = 'red') bou2['command'] = lambda bou2=bou2: bou2.configure(background = 'red') bou4['command'] = lambda bou4=bou4: bou4.configure(background = 'red') bou6['command'] = lambda bou6=bou6: bou6.configure(background = 'red') bou7['command']=lambda bou7=bou7: bou7.configure(background='red') bou8['command']=lambda bou8=bou8: bou8.configure(background='red') bou10['command']=lambda bou10=bou10: bou10.configure(background='red') bou11['command']=lambda bou11=bou11: bou11.configure(background='red') bou14['command']=lambda bou14=bou14: bou14.configure(background='red') bou16['command']=lambda bou16=bou16: bou16.configure(background='red') bou17['command']=lambda bou17=bou17: bou17.configure(background='red') bou18['command']=lambda bou18=bou18: bou18.configure(background='red') bou20['command']=lambda bou20=bou20: bou20.configure(background='red') bou21['command']=lambda bou21=bou21: bou21.configure(background='red') bou22['command']=lambda bou22=bou22: bou22.configure(background='red') bou23['command']=lambda bou23=bou23: bou23.configure(background='red') bou24['command']=lambda bou24=bou24: bou24.configure(background='red') bou25['command']=lambda bou25=bou25: bou25.configure(background='red') bou26['command']=lambda bou26=bou26: bou26.configure(background='red') bou27['command']=lambda bou27=bou27: bou27.configure(background='red') bou1.grid(row=1, column=1) bou2.grid(row=1, column=2) bou4.grid(row=1, column=4) bou6.grid(row=1, column=6) bou7.grid(row=1, column=7) bou8.grid(row=1, column=8) bou10.grid(row=2, column=1) bou11.grid(row=2, column=2) bou14.grid(row=2, column=5) bou16.grid(row=2, column=7) bou17.grid(row=2, column=8) bou18.grid(row=2, column=9) bou20.grid(row=3, column=2) bou21.grid(row=3, column=3) bou22.grid(row=3, column=4) bou23.grid(row=3, column=5) bou24.grid(row=3, column=6) bou25.grid(row=3, column=7) bou26.grid(row=3, column=8) bou27.grid(row=3, column=9) liste3=[1,54,86] liste5=[8,41,75] liste9=[35,47,100] liste12=[34,40,88] liste13=[7,36,71] liste15=[10,51,96] liste19=[22,62,76] n1=3 t=0 t3=randint(0 ,2) bou3=Button(fen1, text=(liste3[t3]), background='white') t5=randint(0 ,2) bou5=Button(fen1, text=(liste5[t5]), background='white') t9=randint(0 ,2) bou9=Button(fen1, text=(liste9[t9]), background='white') t12=randint(0 ,2) bou12=Button(fen1, text=(liste12[t12]), background='white') t13=randint(0 ,2) bou13=Button(fen1, text=(liste13[t13]), background='white') t15=randint(0 ,2) bou15=Button(fen1, text=(liste15[t15]), background='white') t19=randint(0 ,2) bou19=Button(fen1, text=(liste19[t19]), background='white') bou3['command'] = lambda bou3=bou3: bou3.configure(background = 'red') bou9['command']=lambda bou9=bou9: bou9.configure(background='red') bou5['command'] = lambda bou5=bou5: bou5.configure(background = 'red') bou12['command']=lambda bou12=bou12: bou12.configure(background='red') bou13['command']=lambda bou13=bou13: bou13.configure(background='red') bou15['command']=lambda bou15=bou15: bou15.configure(background='red') bou19['command']=lambda bou19=bou19: bou19.configure(background='red') bou3.grid(row=1, column=3) bou5.grid(row=1, column=5) bou9.grid(row=1, column=9) bou12.grid(row=2, column=3) bou13.grid(row=2, column=4) bou15.grid(row=2, column=6) bou19.grid(row=3, column=1) bou28 = Button(fen1,text='Quitter', background='blue', command=fen1.destroy) bou28.grid(row=2, column=10) bou29 = Button(fen1,text='Changer de grille', background='yellow', command=fen1.destroy) bou29.grid(row=1, column=10)