| 12
 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
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 
 | from Tkinter import *
# définition des gestionnaires
# d'événements :
 
def start_it():
    print 'début de l animation'
    global flag
    global no
    print 'flag av',flag
    flag =1
    print 'flag ap',flag
 
def num(no) :
    print 'num flag av',flag
    if flag == 1 :       
        cpt[no]=0
        nbf[no]=nbf[no]+1
        txt1 = Label(fen1, text = cpt[no])
        txt2 = Label(fen1, text = nbf[no])
        txt1.grid(row =1,column=no)
        txt2.grid(row =2,column=no)
        t = range(36)
        print 'num',no
        for a in t:
            if a <> no:
                cpt[a]=cpt[a]+1
                txt1 = Label(fen1, text = cpt[a])
                txt2 = Label(fen1, text = nbf[a])
                txt1.grid(row =1,column=a)
                txt2.grid(row =2,column=a)
 
    elif flag == 0 :
        txt1 = Label(fen1, text = cpt[no])
        txt2 = Label(fen1, text = nbf[no])
        txt1.grid(row =1,column=no)
        txt2.grid(row =2,column=no)
 
#========== Programme principal =============
 
# les variables suivantes seront utilisées de manière globale :
flag = 0
cpt =[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
nbf =[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
# Création du widget principal ("parent") :
fen1 = Tk()
fen1.title("ecart roulette")
 
bouq = Button(fen1,text='Quit', width =4,command=fen1.quit)
bouq.grid(row =4,column =3)
 
bou0 = Button(fen1, text='0', width =4, command = num(0))
bou0.grid(row =0,column =0)
bou1 = Button(fen1, text='1', width =4, command=num(1) )
bou1.grid(row =0,column =1)
bou2 = Button(fen1, text='2', width =4, command=num(2))
bou2.grid(row =0,column =2)
bou3 = Button(fen1, text='3', width =4, command=num(3))
bou3.grid(row =0,column =3)
bou4 = Button(fen1, text='4', width =4, command=num(4))
bou4.grid(row =0,column =4)
bou5 = Button(fen1, text='5', width =4, command=num(5))
bou5.grid(row =0,column =5)
bou6 = Button(fen1, text='6', width =4, command=num(6))
bou6.grid(row =0,column =6)
bou7 = Button(fen1, text='7', width =4, command=num(7))
bou7.grid(row =0,column =7)
bou8 = Button(fen1, text='8', width =4, command=num(8))
bou8.grid(row =0,column =8)
bou9 = Button(fen1, text='9', width =4, command=num(9))
bou9.grid(row =0,column =9)
 
bou10 = Button(fen1, text='10', width =4, command=num(10))
bou10.grid(row =0,column =10)
bou11 = Button(fen1, text='11', width =4, command=num(11))
bou11.grid(row =0,column =11)
bou12 = Button(fen1, text='12', width =4, command=num(12))
bou12.grid(row =0,column =12)
bou13 = Button(fen1, text='13', width =4, command=num(13))
bou13.grid(row =0,column =13)
bou14 = Button(fen1, text='14', width =4, command=num(14))
bou14.grid(row =0,column =14)
bou15 = Button(fen1, text='15', width =4, command=num(15))
bou15.grid(row =0,column =15)
bou16 = Button(fen1, text='16', width =4, command=num(16))
bou16.grid(row =0,column =16)
bou17 = Button(fen1, text='17', width =4, command=num(17))
bou17.grid(row =0,column =17)
bou18 = Button(fen1, text='18', width =4, command=num(18))
bou18.grid(row =0,column =18)
bou19 = Button(fen1, text='19', width =4, command=num(19))
bou19.grid(row =0,column =19)
 
bou20 = Button(fen1, text='20', width =4, command=num(20))
bou20.grid(row =0,column =20)
bou21 = Button(fen1, text='21', width =4, command=num(21))
bou21.grid(row =0,column =21)
bou22 = Button(fen1, text='22', width =4, command=num(22))
bou22.grid(row =0,column =22)
bou23 = Button(fen1, text='23', width =4, command=num(23))
bou23.grid(row =0,column =23)
bou24 = Button(fen1, text='24', width =4, command=num(24))
bou24.grid(row =0,column =24)
bou25 = Button(fen1, text='25', width =4, command=num(25))
bou25.grid(row =0,column =25)
bou26 = Button(fen1, text='26', width =4, command=num(26))
bou26.grid(row =0,column =26)
bou27 = Button(fen1, text='27', width =4, command=num(27))
bou27.grid(row =0,column =27)
bou28 = Button(fen1, text='28', width =4, command=num(28))
bou28.grid(row =0,column =28)
bou29 = Button(fen1, text='29', width =4, command=num(29))
bou29.grid(row =0,column =29)
 
bou30 = Button(fen1, text='30', width =4, command=num(30))
bou30.grid(row =0,column =30)
bou31 = Button(fen1, text='31', width =4, command=num(31))
bou31.grid(row =0,column =31)
bou32 = Button(fen1, text='32', width =4, command=num(32))
bou32.grid(row =0,column =32)
bou33 = Button(fen1, text='33', width =4, command=num(33))
bou33.grid(row =0,column =33)
bou34 = Button(fen1, text='34', width =4, command=num(34))
bou34.grid(row =0,column =34)
bou35 = Button(fen1, text='35', width =4, command=num(35))
bou35.grid(row =0,column =35)
bou36 = Button(fen1, text='36', width =4, command=num(36))
bou36.grid(row =0,column =36)
 
bour = Button(fen1, text='debu', width =4, command=start_it())
bour.grid(row =4,column =1)
 
bous = Button(fen1, text='save', width =4, )
bous.grid(row =4,column =2)
 
 
fen1.mainloop() # démarrage du réceptionnaire d'événements
fen1.destroy() # destruction (fermeture) de la fenêtre | 
Partager