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
| from Tkinter import *
n_equip=2
choix=[]
choix.append(['1-Inraci',0])
choix.append(['2-Prygogine',0])
def affiche_liste(n):
global listbox, choix
for k in range (n):
if choix[k][1]==0: coul1='orange';coul2='black'
else: coul1='blue';coul2='white'
listbox.itemconfig(k,background=coul1,foreground=coul2)
fen.update()
def clic(evt):
global listbox, choix
index = listbox.curselection()
s=int(index[0])
choix[s][1]=(choix[s][1]+1)%2
affiche_liste(n_equip)
def impr() :
global listbox, choix, n_equip
index = listbox.curselection()
listbox.get(index)
s=int(index[0])
affiche_liste(n_equip)
print(choix)
fen.destroy()
fen=Tk()
listbox = Listbox(fen, width=50,height=n_equip)
for k in range(n_equip):
listbox.insert(k,choix[k][0])
listbox.pack()
affiche_liste(n_equip)
listbox.bind('<ButtonRelease-1>',clic)
bouton = Button(fen, text='Terminé', command=impr)
bouton.pack()
fen.title("Tournoi de PingPong")
fen.mainloop()
print "Equipes Séléctionnées",[1] |
Partager