Reputation: 334
Someone know if it's possible to change the color of a pixel in a canvas without using un object, so without using something like canvas.create_oval
or canvas.create_rectangle
?
Upvotes: 2
Views: 3801
Reputation: 386352
There is no way to color a pixel other than to create a 1x1 pixel object of some sort. And yes, at some point you will experience performance problems. The canvas simply wasn't designed to be used this way.
If you're really needing to create a large area in which you can manage individual pixels, you can create a canvas with a single image that is the same size as the canvas. You can then set the color of individual pixels on the image through the photo image interface.
Upvotes: 5
Reputation: 21517
Within tkinter
itself, it's impossible.
Even if you manage to change a pixel on canvas window (which is possible with X11 and Windows APIs in a platform-dependent way), you'd have to ensure it's repainted properly.
You can, of course, place
a frame
of size 1x1 over the canvas, with a background color you want. This way, pixel is "changed" and no canvas object is created. If there's a real (though strange) problem behind a question, this trick could be a solution.
Upvotes: 0