Hi all, Can someone help me to resolve the following issue:
I have four rectangles flashing at different frequencies. If I select the first rectangle by some event.keys, I should be able to navigate to the next set of stimuli, which are again different set of rectangles with reduced size. Again when I select one of the rectangles by an event.key, I should be able to navigate to third set of rectangles.
For the first loop, when I call event.getkeys() on my first rectangle, i am able to navigate to the second loop which displays second set of rectangles.
But on calling event.keys in one of the rectangles of second set, i am not able to navigate to the third set of rectangles.
Here is the snippet of my code:
start = core.getTime()
cnt = 0
while cnt < 1000:
second = core.getTime() - start
sin_val_one = 1.0+0.5*np.sin(2 * np.pi * second * float(freq_one))
sin_val_two = 1.0+0.5*np.sin(2 * np.pi * second * float(freq_two))
sin_val_three = 0.0+0.5*np.sin(2 * np.pi * second * float(freq_three))
sin_val_four = 0.0+0.5*np.sin(2 * np.pi * second * float(freq_four))
rect_one.opacity = sin_val_one
rect_two.opacity = sin_val_two
rect_three.opacity = sin_val_three
rect_four.opacity = sin_val_four
textStim1.draw()
textStim2.draw()
textStim3.draw()
textStim4.draw()
rect_one.draw()
rect_two.draw()
rect_three.draw()
rect_four.draw()
if 'r' in event.getKeys():
textStim1.text=text1_1
textStim2.text=text1_2
textStim3.text=text1_3
textStim4.text=text1_4
textStim1.pos = pos_one
textStim2.pos = pos_two
textStim3.pos = pos_three
textStim4.pos = pos_four
win.flip()
# win.update()
second = core.getTime() - start
sin_val_one = 1.0+0.5*np.sin(2 * np.pi * second * float(freq_one))
sin_val_two = 1.0+0.5*np.sin(2 * np.pi * second * float(freq_two))
sin_val_three = 0.0+0.5*np.sin(2 * np.pi * second * float(freq_three))
sin_val_four = 0.0+0.5*np.sin(2 * np.pi * second * float(freq_four))
rect_one.size=15
rect_two.size=15
rect_three.size=15
rect_four.size=15
rect_one.opacity = sin_val_one
rect_two.opacity = sin_val_two
rect_three.opacity = sin_val_three
rect_four.opacity = sin_val_four
textStim1.draw()
textStim2.draw()
textStim3.draw()
textStim4.draw()
rect_one.draw()
rect_two.draw()
rect_three.draw()
rect_four.draw()
win.flip()
event.clearEvents()
if 'b' in event.getKeys():
win.flip()
textStim1.text="A"
textStim2.text="B"
textStim3.text="C"
textStim4.text="D"
textStim1.pos = pos_one
textStim2.pos = pos_two
textStim3.pos = pos_three
textStim4.pos = pos_four
second = core.getTime() - start
sin_val_one = 1.0+0.5*np.sin(2 * np.pi * second * float(freq_one))
sin_val_two = 1.0+0.5*np.sin(2 * np.pi * second * float(freq_two))
sin_val_three = 0.0+0.5*np.sin(2 * np.pi * second * float(freq_three))
sin_val_four = 0.0+0.5*np.sin(2 * np.pi * second * float(freq_four))
rect_one.size=10
rect_two.size=10
rect_three.size=10
rect_four.size=10
rect_one.opacity = sin_val_one
rect_two.opacity = sin_val_two
rect_three.opacity = sin_val_three
rect_four.opacity = sin_val_four
textStim1.draw()
textStim2.draw()
textStim3.draw()
textStim4.draw()
rect_one.draw()
rect_two.draw()
rect_three.draw()
rect_four.draw()
win.flip()
elif 'delete' in event.getKeys():
print('quitting')
# quit_program.set()
core.quit()
win.close()
print('main window closed')
break
else :
win.flip()
cnt += 1
Any help is greatly appreciated. Thanks in Advance!