How would you optimize drawing thousants of squares with tkinter?
I am making a 2d cave generation script out of boredom and I've just added a method for showing the map visually. My current scripts works with a 2d array of numbers and it loops through it and draws a different colored square for each number with it's color and position based on the number and it's order in the arrays. The main problem is that the approach is currently drawing literal tens of thausants of squares when i turn it on (I'm testing with a 150x150 map rn and am scared to go higher). How could I optimize this?
Current code:
def draw_map(self, file_mame):
for y in range(self.map_height):
for x in range(self.map_width):
self.c.create_rectangle(x * self.sqr_size, y * self.sqr_size, (x + 1) * self.sqr_size, (y + 1) * self.sqr_size, width = 0, fill = self.gfx_dict[self.map[y][x]])
self.c.mainloop()