I'm using Tkinter to create a window in python and a canvas to display graphics in the window. This is working fine so far.
But I have a two dimensional list containing colours that I would like to directly place on the canvas.
Example
I have a class defined (named CRGB) that has three variables: r, g and b. These are the red, green and blue values of a colour, and are integers between 0 and 255.
I also have a two-dimensional list, which contains CRGB objects with the colour data.
I then have a Canvas (defined in a variable called screenCanvas) which is the same size as the 2D list.
How would I transfer the pixels from the 2D list to the canvas?
Notes: I would like the code to work on Mac AND Windows, and not use any external libraries (libraries not included in Python by default.)
The canvas has no way to draw an individual pixel, except to draw a line that is exactly one pixel long and one pixel wide.
If you only need to place pixels, and don't need the other features of the canvas widget, you can use a PhotoImage object. An instance of PhotoImage has methods for setting individual pixels.
Drawing individual pixels to a canvas in tkinter