I am trying to make a toggle when the button is pressed but I cant seem to be able to get the index of the pressed button.
class Canvas_Grid(Frame):
def __init__(self, parent = None, row = 8, column = 8):
self.parent = parent
self.parent.title('Grid predictor')
Frame.__init__(self, self.parent)
self.pack(expand=True)
self.canvas= Canvas(self)
self.canvas.config(width = 1000,height = 1000)
self.canvas.pack(expand = 'yes', fill = 'both')
def Index_grabber():
#here we are going to grab the index of the Button that was clicked
pass
self.Coordinates = []
for x in range(row):
for y in range(column):
self.Coordinates += [(x, y, False)]
Button(self.canvas, text = (False), height = 1, width = 2, bg = 'white', command = lambda:Index_grabber()).grid(row = x, column = y, padx = 0,pady = 0)
if __name__ == '__main__':
root= Tk()
root.geometry('800x800')
SizeX, SizeY = 10, 10
cg=Canvas_Grid(root, row = SizeX, column = SizeY)
root.mainloop()