I have created 9 buttons with a loop and want each of them to display "x" when clicked. However, the command function is not properly executing for each button.
I already tried using lambda... I think the issue might be in the way that I named each Button?
def create_buttons(self):
buttoncounter = 1
for i in range(9):
self.temp_string = "b" + str(buttoncounter)
self.temp_string = Button(self, text = "\n\t\n\t\n\t")
self.temp_string.grid(row = (20 + i), column = (20))
self.temp_string.configure(command=partial(self.mark_box,
buttoncounter))
buttoncounter += 1
def mark_box(self, num):
turnlist = ["x", "o"]
self.temp_string = "b" + str(num)
self.temp_string.configure(text = "x")
I want to be able to click a button and have it check itself off, but when I click any of the 9 buttons it only checks off the 9th one.