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 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
|
def sous_ensemble():
global liste2
global e_new
global dataset3
global compoT2
global taille
global arret
global resume
global nameP
global lb1
global graph
global grouP
global population
global association
global groupe
if arret != 1: #condition d'arrêt de ma fenêtre global
global graph
graph = Tk()
graph.title( "Association d'éléments pour l'analyse" )
groupe = '' #On initie la variable qui va contenir le nom du groupe
global Check
Check = [0]*len(resume['Inclusion']) #statut de mes boutons à cocher
for y in range(0,len(Check)):
Check[y] = IntVar() #j'en fais un Int - je sais que ça peut marcher avec un bool
# Je prévois le fait qu'il puisse y avoir tellement d'élément qu'il faille faire plusieurs colonnes, ça m'évite les scroll
nombre_colonne = int(round_up(len(resume['Inclusion'])/25))
# Je créer mes Check à partir de la liste 'resume['Inclusion'][x]'
colonne_courante=0
if nombre_colonne == 1:
for x in range(len(resume['Inclusion'])):
l = Checkbutton(graph, text=resume['Inclusion'][x], variable=Check[x],onvalue = 1, offvalue = 0)
l.grid(row = x, column = colonne_courante, sticky = 'w')
if nombre_colonne > 1:
for x in range(0,24):
Check[x].set(0)
l = Checkbutton(graph, text=resume['Inclusion'][x], variable=Check[x],onvalue = 1, offvalue = 0)
l.grid(row = x, column = colonne_courante, sticky = 'w')
colonne_courante = 1
while colonne_courante < nombre_colonne-1:
for x in range(25*colonne_courante,25*(colonne_courante+1)-1):
Check[x].set(0)
l = Checkbutton(graph, text=resume['Inclusion'][x], variable=Check[x],onvalue = 1, offvalue = 0)
l.grid(row = x-25*colonne_courante, column = colonne_courante, sticky = 'w')
colonne_courante = colonne_courante +1
if colonne_courante == nombre_colonne-1:
for x in range(25*colonne_courante,len(resume['Inclusion'])-1):
Check[x].set(0)
l = Checkbutton(graph, text=resume['Inclusion'][x], variable=Check[x],onvalue = 1, offvalue = 0)
l.grid(row = x-25*colonne_courante, column = colonne_courante, sticky = 'w')
colonne_courante = colonne_courante +1
# Mes différents boutons
bouton_associer = Button(graph, text='Associer', command=associer_inclusion)
bouton_associer.grid(row = 0, column = nombre_colonne+1, sticky = 'N')
bouton_supprimer = Button(graph, text='Enlever', command=supprimer_liste)
bouton_supprimer.grid(row = 0, column = nombre_colonne+2, sticky = 'N')
bouton_enregistrer = Button(graph, text='Enregistrer', command=enregistrer_liste)
bouton_enregistrer.grid(row = 0, column = nombre_colonne+3, sticky = 'N')
#La listbox
lb1 = Listbox(graph, width = 60, height = 30)
lb1.grid(row = 1, column = nombre_colonne+1, columnspan = 3, rowspan=len(resume['Inclusion']))
info = Label(graph, text="Pour défiler en latéral, cliquer sur la ligne et faire glisser")
info.grid(row = 26, column = nombre_colonne+1, columnspan = 3, rowspan=len(resume['Inclusion']))
bouton_quitter = Button(graph, text='Valider', command=fermer_graph)
bouton_quitter.grid(row = 27, column = nombre_colonne+4, sticky = 'E')
graph.mainloop()
#
#### La fonction qui permet d'associer
def associer_inclusion():
global groupe
global Check
global resume
global lb1
Check2 = [0]*len(Check) # J'ai souvent des bug quand je travaille directement sur les valeurs issues de Checkbox donc, je les lis et les stock dans une autre variable
for x in range(0,len(resume['Inclusion'])-1):
Check2[x] = float(Check[x].get())
for x in range(0,len(resume['Inclusion'])-1):
if Check2[x] == 1:
if groupe != "":
groupe = groupe +' + '+str(resume['Inclusion'][x]) #j'assemble le nom du groupe
if groupe == "":
groupe = str(resume['Inclusion'][x])
Check[x].set(0) #Je décoche
lb1.insert(END, groupe) #Je mets à jour la listbox en ajoutant le nom à la fin
groupe = '' #Je vide groupe |
Partager