when i run this code an icon for the image is created but when clicked it says that no preview is availeble any help would be grately apretiated. heres the code.

from Image import *
import ImageDraw

z=1

win=new('RGB', (400,400), 'rgb(255,255,255)')
win.save('c:\\Documents and Settings\\bradley\\desktop\\python programs\\frac.png')

while z < 100000:

    x=(z**+1)
    y=(z**+1)
    
    frac=open('c:\\Documents and Settings\\bradley\\desktop\\python programs\\frac.png')

    draw=ImageDraw.Draw(frac)
    draw.point((x,y),fill=0)

    frac.save('c:\\Documents and Settings\\bradley\\desktop\\python programs\\frac.png')

    z=x

print 'im working'

You really want to open the file 100000 times in the loop?
You need to close the open file it before you save to it.

no i dont want to open the file 100000 times i want the result of the function to be used as the variable z and then run through the function again and again until the value of z = 100000, which sence were talking about exponential growth shouldnt take all that long probably something like 100 iterations if that maby more like 50. and what do you mean i need to close the open file befor i save to it ? The file needs to be opend and writen befor being closed and this open then save pattern has worked for other pictures in the past i.e. ellipses and padles for a version of pong. i just want to know why its opening and saving an icon but aperrently none of the other data?

well i figured it out it was a simple syntactical error i just forgot to give the value i was raising it to after the **, that and i moved the functions inside the while loop and the open comands outside it. so i got the code working now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.