[Tutor] plotting pixels
Lie Ryan
lie.1296 at gmail.com
Sat Sep 18 21:37:11 CEST 2010
> It appears that the Tk canvas widget does not support simply
> plotting a pixel. However, I can plot a line only one pixel long.
> I wonder why they do not simply provide the pixel plot primitive? I
> have seen very many graphics packages that do this and I have always
> wondered why. The primitive obviously exists in the underlying
> code, because that is what everything else is built upon. Does Tk
> actually have a something like a create_pixel method in the canvas
> widget that I have missed?
You don't want that.
Tkinter's Canvas is a Smart Canvas, each lines and shapes corresponds to
a Tcl/Tk object. If you want to plot a 800*600 image pixel-per-pixel in
Tkinter's Canvas, then Tkinter would have to create 480000 Tcl Objects.
If you want to draw pixels and lines directly, Tkinter Canvas isn't
suitable for that. Try using a different Canvas, one that uses a
Stateless Canvas.
More information about the Tutor
mailing list