I am doing a whiteboard in Tkinter to draw and animation. I tried to make a system to change color using the matplotlib.colors.CSS4_COLORS palette:
row = 0
col = 0
color_list = sorted(mcolors.CSS4_COLORS.values(), key=lambda x: tuple(mcolors.rgb_to_hsv(mcolors.to_rgb(x))))
for color in color_list:
id = self.color_buttons.create_rectangle(col*30, row*30, col*30+30, row*30+30, fill=color)
self.color_buttons.tag_bind(id, '<Button-1>', lambda x: self.change_color(color))
col += 1
if col == 6:
col = 0
row += 1
However, when I click on one of the rectangles, the new color always becomes the last of the list. As if I had clicked on the last rectangle.