from tkinter import * from tkinter.ttk import * from tkinter.messagebox import * L = [] #Liste vide w = Tk() w.title("Gestion Ecole") w.geometry("400x260") Label(w,text="CODE:").place(x = 20 , y = 20) Label(w,text="NOM:").place(x = 20 , y = 60) Label(w,text="PRENOM:").place(x = 20 , y = 100) txt_code = Entry(w) txt_code.place(x = 80 , y = 20) txt_nom = Entry(w) txt_nom.place(x = 80 , y = 60) txt_prenom = Entry(w) txt_prenom.place(x = 80 , y = 100) #Enregistrer def Enregistrer(): code = int(txt_code.get()) #code est un entier nom = txt_nom.get() prenom = txt_prenom.get() L.append([code,nom,prenom]) showinfo("Enregistrer","Opération effectuée") print(L) btn1 = Button(w,text="Enregistrer" , command=Enregistrer) btn1.place(x = 20 , y = 140) #Rechercher def Rechercher(): code = int(txt_code.get()) for personne in L: if personne[0] == code: txt_nom.delete(0,END) txt_nom.insert(0,personne[1]) txt_prenom.delete(0,END) txt_prenom.insert(0,personne[2]) btn2 = Button(w,text="Rechercher" , command=Rechercher) btn2.place(x = 260 , y = 60) #Modifier def Modifier(): code = int(txt_code.get()) for personne in L: if personne[0] == code: personne[1] = txt_nom.get() personne[2] = txt_prenom.get() showinfo("Modifier","Opération effectuée") print(L) btn3 = Button(w,text="Modifier" , command=Modifier) btn3.place(x = 110 , y = 140) #Supprimer def Supprimer(): code = int(txt_code.get()) i = 0 for personne in L: if personne[0] == code: L.pop(i) showinfo("Supprimer","Opération effectuée") i += 1 print(L) btn3 = Button(w,text="Supprimer" , command=Supprimer) btn3.place(x = 220 , y = 140) w.mainloop()