psychopy.org | Reference | Downloads | Github

Cant get countdown to perform activities

#1

Hi, I’m a newbie to coding in general. I’m trying to have multiple phases in an experiment, where I can switch what’s in a window (clear and present new items). I have a countdown set to display a circle, then remove it and display these two boxes.

The problem is, the countdown happens with a blank screen instead and then the boxes show up (I did something before where all of them show up at the same time). I need the circle to be there for a couple of seconds then disappear instead! Gracias in advance!

from __future__ import absolute_import, division, print_function
from psychopy import visual, gui, event, core, logging, clock
from psychopy.visual import ShapeStim

win1 = visual.Window([800, 800])
win1.color = [0, 0, 0]
win1.getMsPerFrame(nFrames=60, showVisual=False, msg='', msDelay=0.0)
circle = visual.Circle(win1, color='orange', size=.3, pos=(0, 0))
square1 = visual.Rect(win1, width=.5, height=.5, color='orange', size=.75, pos=(.5, 0))
square2 = visual.Rect(win1, width=.5, height=.5, color='blue', size=.75, pos=(-.5, 0))
mymouse = event.Mouse()

# test logging sitch
globalClock = core.Clock()  # if this isn't provided the log times will reflect secs since python started
logging.setDefaultClock(globalClock)
logging.console.setLevel(logging.DEBUG)  # receive nearly all messages
logDat = logging.LogFile('logLastRun.log',
                         filemode='w',  # if you set this to 'a' it will append instead of overwriting
                         level=logging.DEBUG)  # errors, data and warnings will be sent to this logfile

timer = core.CountdownTimer()
timer.add(3)
while not event.getKeys('q'):
    if timer.getTime() > 0:
        circle.draw()
    circle.draw()
    square1.draw()
    square2.draw()

    if mymouse.isPressedIn(shape=square1, buttons=(0, 1, 2)):
        print('R')
        event.getKeys = 'q'
    if mymouse.isPressedIn(shape=square2, buttons=(0, 1, 2)):
        print('L')
        event.getKeys = 'q'
    win1.flip()

    # log('R')
    # core.wait(3.0)

win1.logOnFlip(msg='something important', level=logging.INFO, obj=None)

# hlogging.flush()
win1.close