Python 3 - Tkinter

ça fait une éternité que je n'ai pas joué avec tkinter - quand je veux une interface utilisateur sur mon Mac j'utilise xCode mais essayez un truc comme cela

import tkinter as tk


def clickEtiquette(ligne, col):
    print(f"Etiquette choisie en Ligne {ligne} et Col {col}")

def clickBouton():
    print("Le bouton a été cliqué")
  
affichage = tk.Tk()
affichage.title("Grille d'étiquettes")

for l in range(9):
    for c in range(9):
        label = tk.Label(affichage, text=f"case ({l}, {c})", borderwidth=1, relief="solid", width=15, height=3)
        label.grid(row=l, column=c)
        label.bind("<Button-1>", lambda event, ligne=l, col=c: clickEtiquette(ligne,col))

bouton = tk.Button(affichage, text="Cliquez-moi !", command=clickBouton)
bouton.grid(row=9, column=0, columnspan=9, sticky="w", padx=10, pady=10)  


affichage.mainloop()

➜ le bind est dans les boucles for