1

i have objects from db and delete button. How to mark buttons to delete them correctly by id or something. My code doesn't work, it delete only the last one. I use sqlalchemy with sqlite for db.

def show_coaches():
    col=0
    row=0
    for i in search_coach(): #returns arr objects
        e = tk.Label(frame_bottom, text=i.name, relief=tk.GROOVE)
        e.grid(row=row, column=col,padx=5, pady=5, sticky=tk.NSEW)
        a = tk.Button(frame_bottom, text=f"del: {i}", command=lambda: [delete_coach(i), clear_frame(), show_coaches()])
        a.grid(row=row, column=col+1, padx=5, pady=5)
        col += 2
        if col % 6 == 0:
            row+=1
            col=0
Jurody
  • 11
  • 1
  • 1
    Does this answer your question? [Lambda in a loop](https://stackoverflow.com/questions/19837486/lambda-in-a-loop) – acw1668 May 07 '21 at 07:21

0 Answers0