I have an issue, I created a table of buttons using a loop, and I saved the button's names in a list, now I want to change the text of the buttons when one button is clicked. I don't konw how.
this is the loop where i create the table
def grid(n):
i = n*n
for widget in LeftFrame.winfo_children():
widget.destroy()
for i in range(n):
for row in range(n):
for col in range(n):
button = Button(LeftFrame, text=' ', width=12, height=6, command=lambda: checker(button, i))
button.grid(row=row, column=col)
button_identities.append(button)
and this is the function on click of the button
def checker(buttons, i):
print(i)
global click, button_identities
print(button_identities)
bname = (button_identities[i])
print(bname)
if buttons["text"] == ' ' and click == True:
buttons["text"] = 'X'
click = False
# scorekeeper()
elif buttons['text'] == ' ' and click == False:
buttons['text'] = 'O'
click = True
# scorekeeper()
there is a method to check the text from the button name in the last function