1

When'People .config' runs it only changes the bottom right button, is there any way to change it so that whichever button in my grid is clicked changes colour.

def click(row, col):

    label.configure(text="you booked row %s column %s" % (row, col), bg='black', fg='yellow', font='Times 
    22')
    print("you booked row %s column %s" % (row, col))
    People.config(bg='red')






root.configure(bg="black")
Seats = Frame(root, height=100, width =200, bg = 'black')
Seats.grid(row=0, column = 1)

for row in range(10):

    for col in range(20):
        People = Button(Seats, bg='Orange',text="%s,%s" % (row, col),
                       command=lambda row=row, col=col: click(row, col))


        People.grid(row=row, column=col+1, pady=1,padx=1)
  • ***it only changes the bottom right button***: You use `People` which refers to the last `Button` from the `for ...` loop. Follow this approach [Using a event callback](https://stackoverflow.com/a/60197776/7414759) – stovfl Apr 14 '20 at 10:29

0 Answers0