Direct pixel-by-pixel drawing (with Tk) 
Author Message
 Direct pixel-by-pixel drawing (with Tk)

Hello,

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.

Now, of course, one solution is to draw a bunch of lines of length 1,
but TK seems to want to remember each {*filter*}y line its drawn, which
is a bit of overkill and a memory hog.

I'm doing this on Linux and Windows, so a platform-independent
solution would rock.

Thanks,
jml

PS. I'm not afraid of reading documentation :)

--
Jonathan Mark Lange
http://www.*-*-*.com/ - For God's sake Jim, I'm a programmer, not a designer!



Sun, 01 Jun 2003 19:06:58 GMT  
 Direct pixel-by-pixel drawing (with Tk)

Quote:

>Hello,

>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.

>Now, of course, one solution is to draw a bunch of lines of length 1,
>but TK seems to want to remember each {*filter*}y line its drawn, which
>is a bit of overkill and a memory hog.

>I'm doing this on Linux and Windows, so a platform-independent
>solution would rock.

>Thanks,
>jml

>PS. I'm not afraid of reading documentation :)

Unless you really *have* to use TK, take a look at wxPython. www.wxpython.org

--
Dale Strickland-Clark
Out-Think Ltd
Business Technology Consultants



Sun, 01 Jun 2003 21:45:41 GMT  
 Direct pixel-by-pixel drawing (with Tk)

Quote:

> 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
strings).

    label = Label()
    label.pack()

    data = (
        ("#000000", "#404040"),
        ("#808080", "#FFFFFF")
    )

    im = PhotoImage(width=len(data[0]), height=len(data))
    im.put(data)

    label.config(photo=im)
    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:

    http://www.pythonware.com/products/pil/index.htm

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->



Mon, 02 Jun 2003 07:18:53 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Win32 ASM programming of Sound and Painting to screen Pixel by pixel

2. Win32 ASM programming of Sound and Painting to screen Pixel by pixel

3. How to draw a pixel in an STk Canvas

4. More help with assembly draw pixel

5. Help with assembly draw pixel function

6. How To : draw a pixel in 800x600x16M

7. Fastest ASM to plot a pixel in a drawing buffer

8. Last pixel of a line apparently not drawn

9. How to draw a _single_ pixel in a canvas widget

10. wish4.2/irix5.3 off by one pixel when drawing in canvas widget

11. Problem with drawing pixel...

12. Tk - set a pixel in a canvas?

 

 
Powered by phpBB® Forum Software