If this template helps then use it. If not then just delete and start from scratch.
Hello, I am using a MacBook and I have the Latest Psycho.Py version for MacBooks.
I am trying to create an experiment where four sliders are present on the screen and participants can end the routine when all sliders are filled by pressing the spacebar.
So far, I have tried adding a coding component and I have also tried to achieve this by adding four separate “keyboars” for each slider, but I have not had any success.
Does anyone have any suggestions?
Dear Eni,
What do you mean by “each slider is filled”? Do you mean the participant has answered each slider? I am also unsure of what the problem is?
Do you mean the trial doesn’t end when the participant presses the spacebar? If that is the case, you only need one keyboard component then make sure on your keyboard component the “Force end of routine” box is checked.
I think it would be easiest to just have 4 separate routines, one for each slider. So each screen would have the question, the slider response, and a keyboard response to go onto the next question.
Issac
Dear Issac,
Thank you for your response.
I am currently running a laboratory experiment where all four sliders must be visible on the screen. To ensure that the data is properly gathered, the routine must end by pressing the spacebar only when all four sliders have been rated. Do you have any advice on this?
Could you explain in more detail what the actual problem is that you are having? Explain what you would like the program to do, and what it is currently doing instead.
Issac
My goal is for the routine to advance once the four sliders have been rated and the spacebar has been pressed. If only three sliders have been rated and the spacebar has been pressed, the new routine should not begin until all four sliders have been rated.
The problem that I am having is that after the four sliders have been rated, I cannot get the screen to advance to the next routine despite adding a coding component that is supposed to advance to the next routine when the conditions have been fulfilled (4 sliders rated + the spacebar has been released). I tried to add four “Keyboard” component with conditions that they can only proceed when the four sliders have been rated, but that did not work either.
So you only need 1 keyboard component to end the trial, and make sure on your keyboard component the “Force end of routine” box is checked. If it is not checked, it will not end the trial.
I would have to see what conditions you specifically added to know what you did exactly.
Try looking at How to go the next question after response and not force end routine - #5 by Joan_Orpella and Requiring two inputs to end routine (slider + keyboard). It might be the case that the slider component is showing “undefined” instead of a no value as per the explanation there. In yours you would have to do something like
if slider1.getRT() != None and slider2.getRT() != None and slider3.getRT() != None and slider4.getRT() != None and key_resp.keys == 'space':
continueRoutine = False
Or something akin to that. But I do not know how you have set the conditions currently.
Issac
Thank you for your help! I will add these to my project and let you know.
I added the keyboard and code components and the experiment proceeds to the next routine if the keyboard is pressed, despite the sliders not being filled. It seems as if it doesn’t register the code component being present
Hello
Put the code in Each frame.
Best wishes Jens
Hello Jens,
Thank you for the recommendation! I added it to each frame, however, I still face the same problem with the next routine begining after the keyboard is pressed, despite the sliders not being filled. Do you have any other suggestions?
Best,
Eni.
Hello @Eni_Agollari
Here is my approach. I initialise a variable called allowedKeys in the Begin Experiment tab of a code component that is the first aka topmost component in the routine.
Begin experiment
allowedKeys = False
As I want to run the routine more than once, I set the value of allowedKeys to False in the Begin Routine tab.
Begin routine
allowedKeys = False
In the Each Frame tab, I check that there are four slider responses.
Each frame
if slider1.getRT() != None and slider2.getRT() != None and slider3.getRT() != None and slider4.getRT() != None:
allowKeys = True
If there are four responses, I set the value of allowedKeys to True. The keyboard component starts when allowedKeys is True. The keyboad component is set to Force end of routine. I chose this approach to prevent keyboard responses before all slider responses have been selected.
I hope that helps.
Best wishes Jens
Hi Jens,
That did help. Thank you so much!
Best,
Eni.