The following script should load 39 images (since reps = 39), but it seems to only draw the last one. I think it is going through the loops correctly, but not updating the screen accordingly. Any ideas?
def show_win():
f=file(‘c:\documents and settings\sshumat\desktop\cppdata2.txt’,‘r’)
f.seek(0)
str=f.readline()
temp=str.split()
reps=int(temp[0])
for i in range(reps):
time.sleep(.05)
str=f.readline()
temp=str.split()
numberdata=float(temp[0])
str=f.readline()
temp=str.split()
popmax=float(temp[0])
for j in range(numberdata):
str=f.readline()
temp=str.split()
x=float(temp[0])
y=float(temp[1])
pop=float(temp[2])
shade=(pop/(popmax))
glColor3f(shade, shade, shade)
glBegin(GL_POLYGON)
glVertex2f(x/1.0-0.5, y/1.0-0.5)
glVertex2f(x/1.0-0.5, y/1.0+0.5)
glVertex2f(x/1.0+0.5, y/1.0+0.5)
glVertex2f(x/1.0+0.5, y/1.0-0.5)
glEnd()
glBegin(GL_POLYGON)
glVertex2f(x/2.0-0.25, y/2.0-0.25)
glVertex2f(x/2.0-0.25, y/2.0+0.25)
glVertex2f(x/2.0+0.25, y/2.0+0.25)
glVertex2f(x/2.0+0.25, y/2.0-0.25)
glEnd()
Draw.Redraw(1)
glColor3f(1,1,1)
for i in range(490,510):
for j in range(425,435):
glBegin(GL_POLYGON)
glVertex2f(i/2.0-0.25, j/2.0-0.25)
glVertex2f(i/2.0-0.25, j/2.0+0.25)
glVertex2f(i/2.0+0.25, j/2.0+0.25)
glVertex2f(i/2.0+0.25, j/2.0-0.25)
glEnd()
glBegin(GL_POLYGON)
glVertex2f(i/1.0-0.5, j/1.0-0.5)
glVertex2f(i/1.0-0.5, j/1.0+0.5)
glVertex2f(i/1.0+0.5, j/1.0+0.5)
glVertex2f(i/1.0+0.5, j/1.0-0.5)
glEnd()
def ev(evt, val): # event callback for Draw.Register()
global R,G,B,A # … it handles input events
if evt == Draw.ESCKEY or evt == Draw.QKEY:
Draw.Exit() # this quits the script
else:
return
Draw.Redraw(1)
Draw.Register(show_win, ev, None)