Direct pixel-by-pixel drawing (with Tk)
fredrik at effbot.org
Thu Dec 14 00:18:53 CET 2000
Jonathan Lange wrote:
> I'm relatively new to Python (but not to programming), and I'd like to
> muck around by doing some fractal stuff. However, alot of this stuff
> needs (wants?) setting pixels directly.
Create a PhotoImage object, fill it with data, and display it.
One way to update a PhotoImage object is to use the "put"
method. This method takes a tuple of pixel rows, where each
row is a tuple containing color values (names or #rrggbb hex
label = Label()
data = (
im = PhotoImage(width=len(data), height=len(data))
label.im = im # make sure to keep a reference!
Another approach is to use PIL's ImageTk module, and do the
drawing in a PIL Image memory.
PIL sources and docs are available from PythonWare:
<!-- (the eff-bot guide to) the standard python library:
More information about the Python-list