On Sat, Sep 18, 2010 at 9:26 PM, Bill Allen <walle...@gmail.com> wrote:
> > >> Digging a little deeper it seems the idiomatic way to do this in Python >> is to use PIL the Python Imaging Library to create a GIF or bitmap >> image and then insert that into Tkinters cancvas as an image object. >> >> The Pil ImageDraw class has a point() ethod >> >> I've never tried this but it is described in Grayson's (now out of print?) >> >> book on Tkinter where he uses it to draw a Mandelbrot.... >> The book may be available online these days... >> >> Nowdownloadall.com seems to have it although I've no idea >> of the legality of it! >> >> HTH, >> >> Alan G. >> > Yes, to create a gif or a bmp from the iteration results and then to > display that at the end of the run is by far the most efficient way of > producing Mandelbrot and related sets. I have actually done it that way > before. I just have always had a strange preference to see the set as it > is being produced, which is far from efficient. Kind of a very elaborate > progress bar! Anyway, I have no real complaints about the Tk canvas > methods. It has always just been a pet peeve of mine when something as > basic and simple as plotting a pixel is missing. My complaint on this goes > way back to the ancient days when I had to figure out how to write a > plot_pixel primitive in x86 assembler and then build a graphics library of > my own so I could have pixel based graphics on my old monochrome IBM XT > clone that had a Hercules graphics card in it. Those were the days! > Mandelbrot sets in 4 shades of amber-monochrome! ;-) I will check out > that book you referenced. I appreciate everybody's feedback on this. > > -Bill > > > I found this code on the web. It creates a 100x100 tk.photoimage and fills it with a radom colored pixels then displays it. It seems to me that I should be able to adapt this to what I am trying to acomplish. The only difference in the way I am filling the tk.photoimage object. I ran this under Python 3.1.2 with success. I believe the '#%02x%02x%02x' is the format for an image. It is a color photoimage, but I am presuming that if written directly out to a file this would not actually produce a valid, bmp, gif, pgn, etc. Correct? This does seem to be a reasonable solution that is a pure Tk solution. Also it works in Python 3x, whereas the PIL library has not yet been released for 3x. I have not mentioned it before, but using Python 3x only is also one of my requirement, though self-imposed. Can anyone help me better understand this part of the code below? self.i.put('#%02x%02x%02x' % tuple(color),(row,col)) import tkinter, random class App: def __init__(self, t): self.i = tkinter.PhotoImage(width=100,height=100) colors = [[random.randint(0,255) for i in range(0,3)] for j in range(0,10000)] row = 0; col = 0 for color in colors: self.i.put('#%02x%02x%02x' % tuple(color),(row,col)) col += 1 if col == 100: row +=1; col = 0 c = tkinter.Canvas(t, width=100, height=100); c.pack() c.create_image(0, 0, image = self.i, anchor=tkinter.NW) t = tkinter.Tk() a = App(t) t.mainloop()
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor