Hi everyone,
first things first ![]()
OS: Win10
PsychoPy version: v2022.2.5
I used PsychoPy to do a number line estimation task for children using a touch laptop.
In the task there is a line (slider) shown from 0 to 10 or 100 and the kid has to guess the position of a certain number within this line.
The problem is that at the moment the kid would have to double tap in order to give the answer. I would prefer that a single tap would be enough.
I already read some posts (see below) that describe the same problem but unfortunately their solutions did not work out for me (PsychoPy stopped with exit code 1 or the slider was not clickable anymore).
It would be really great if anyone could help me.
As i donât have a lot of experience with coding, i tried to copy the important part from my code (you will find that below). Could you tell me which commands i have to use and where to put them into the code?
Let me know, if any important information is missing that would be needed to get help here ![]()
Thanks in advance ![]()
â Prepare to start Routine âstartbildschirmâ â
continueRoutine = True
routineForceEnded = False
update component parameters for each repeat
setup some python lists for storing info about the mouseja
mouseja.x =
mouseja.y =
mouseja.leftButton =
mouseja.midButton =
mouseja.rightButton =
mouseja.time =
mouseja.clicked_name =
gotValidClick = False # until a click is received
keep track of which components have finished
startbildschirmComponents = [textstartmessage, imageja, mouseja, imagenemo]
for thisComponent in startbildschirmComponents:
thisComponent.tStart = None
thisComponent.tStop = None
thisComponent.tStartRefresh = None
thisComponent.tStopRefresh = None
if hasattr(thisComponent, âstatusâ):
thisComponent.status = NOT_STARTED
reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock=ânowâ)
frameN = -1
â Run Routine âstartbildschirmâ â
while continueRoutine:
# get current time
t = routineTimer.getTime()
tThisFlip = win.getFutureFlipTime(clock=routineTimer)
tThisFlipGlobal = win.getFutureFlipTime(clock=None)
frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
# update/draw components on each frame
# *textstartmessage* updates
if textstartmessage.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
textstartmessage.frameNStart = frameN # exact frame index
textstartmessage.tStart = t # local t and not account for scr refresh
textstartmessage.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(textstartmessage, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'textstartmessage.started')
textstartmessage.setAutoDraw(True)
# *imageja* updates
if imageja.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
imageja.frameNStart = frameN # exact frame index
imageja.tStart = t # local t and not account for scr refresh
imageja.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(imageja, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'imageja.started')
imageja.setAutoDraw(True)
# *mouseja* updates
if mouseja.status == NOT_STARTED and t >= 0.0-frameTolerance:
# keep track of start time/frame for later
mouseja.frameNStart = frameN # exact frame index
mouseja.tStart = t # local t and not account for scr refresh
mouseja.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(mouseja, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.addData('mouseja.started', t)
mouseja.status = STARTED
mouseja.mouseClock.reset()
prevButtonState = mouseja.getPressed() # if button is down already this ISN'T a new click
if mouseja.status == STARTED: # only update if started and not finished!
buttons = mouseja.getPressed()
if buttons != prevButtonState: # button state changed?
prevButtonState = buttons
if sum(buttons) > 0: # state changed to a new click
# check if the mouse was inside our 'clickable' objects
gotValidClick = False
try:
iter(imageja)
clickableList = imageja
except:
clickableList = [imageja]
for obj in clickableList:
if obj.contains(mouseja):
gotValidClick = True
mouseja.clicked_name.append(obj.name)
if gotValidClick:
x, y = mouseja.getPos()
mouseja.x.append(x)
mouseja.y.append(y)
buttons = mouseja.getPressed()
mouseja.leftButton.append(buttons[0])
mouseja.midButton.append(buttons[1])
mouseja.rightButton.append(buttons[2])
mouseja.time.append(mouseja.mouseClock.getTime())
if gotValidClick:
continueRoutine = False # abort routine on response
# *imagenemo* updates
if imagenemo.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# keep track of start time/frame for later
imagenemo.frameNStart = frameN # exact frame index
imagenemo.tStart = t # local t and not account for scr refresh
imagenemo.tStartRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(imagenemo, 'tStartRefresh') # time at next scr refresh
# add timestamp to datafile
thisExp.timestampOnFlip(win, 'imagenemo.started')
imagenemo.setAutoDraw(True)
# check for quit (typically the Esc key)
if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
core.quit()
# check if all components have finished
if not continueRoutine: # a component has requested a forced-end of Routine
routineForceEnded = True
break
continueRoutine = False # will revert to True if at least one component still running
for thisComponent in startbildschirmComponents:
if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
continueRoutine = True
break # at least one component has not yet finished
# refresh the screen
if continueRoutine: # don't flip if this routine is over or we'll get a blank screen
win.flip()
â Ending Routine âstartbildschirmâ â
for thisComponent in startbildschirmComponents:
if hasattr(thisComponent, âsetAutoDrawâ):
thisComponent.setAutoDraw(False)
store data for thisExp (ExperimentHandler)
thisExp.addData(âmouseja.xâ, mouseja.x)
thisExp.addData(âmouseja.yâ, mouseja.y)
thisExp.addData(âmouseja.leftButtonâ, mouseja.leftButton)
thisExp.addData(âmouseja.midButtonâ, mouseja.midButton)
thisExp.addData(âmouseja.rightButtonâ, mouseja.rightButton)
thisExp.addData(âmouseja.timeâ, mouseja.time)
thisExp.addData(âmouseja.clicked_nameâ, mouseja.clicked_name)
thisExp.nextEntry()
the Routine âstartbildschirmâ was not non-slip safe, so reset the non-slip timer
routineTimer.reset()
One of the posts that i tried to use was the following (unfortunately it did not work):