Creating a countdown timer during stimulus

For my thesis, I am doing an experiment containing 96 trials. In these trials, participants need to look at a picture and respond by tapping one of two keys. They need to look at the image for 10 seconds before they can tap the keys. I would like to have a countdown timer for 10 seconds on each trial so participants know when they can respond.
I am really unfamiliar with Psychopy and had a lot of help from my mentor on building the experiment but have no idea how to implement this into my loop.

This is the code that is in the loop right now:

if (key_card.keys==“left”):
rect_pos = (-8, 0)
elif (key_card.keys==“right”):
rect_pos = (8, 0)

avatar_id = randint(0,2)
if (key_card.keys==seq_list[itrial]):
msg = “%s Age: %d\nLook at the picture, and focus on what emotional reactions %s is having to the picture. How is %s feeling right now?\n\nPositive Negative” % (avatar_names[avatar_id], avatar_ages[avatar_id]+int(expInfo[“age”]), avatar_names[avatar_id], avatar_names[avatar_id])
else:
msg = “You Age: %d\nLook at the picture, and focus on what emotional reactions you are having to the picture. How are you feeling right now?\n\nPositive Negative” % (int(expInfo[“age”]))

Thank you for any feedback!

Hello

Perhaps this helps. Note that this count down timer does not exactly last 10 seconds. It lasts a little bit longer. Check the output in Stdout. Uncomment the print command when running the experiment.

CountUp.psyexp (12.6 KB)

Best wishes Jens

Hi Jens!

thank you for this! It already kind of works but not in every trial. I removed this line trials.finished = True # and terminate the loop (use its actual name) because the next trial would move on without me clicking on it. This still happens when I removed it but not in every trial.

Maybe it helps if I just gave you the experiment so here you go:
EXP1.psyexp (129.4 KB)

I was also wondering how to insert a break in the middle of my experiment so participants can have a little rest and resume when they are ready by pressing space. I already tried numerous solutions but it doesn’t work…
Like I said before, my mentor basically made the experiment so I am not always sure what I’m doing… Thanks!!

Hello

One can not run your program without your condition files and your stimuli.

Attached is a toy programme which presents a 10-second countdown timer, then a routine in which you have to press space to continue. The loop is repeated five times, with a pause on the third round.

CountUp.psyexp (22.6 KB)

I am using PsychoPy version 2024.1.4. Which version are you using?

Best wishes Jens