Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] Double tap key when answering question

edited February 2016 in OpenSesame

Hi, do anyone know why I need to tap the key twice in order to clear the canvas?
For the DISPLAY question part?

from openexp.canvas import canvas
my_canvas = canvas(exp)
my_canvas.text(sentence, center=False, x=60, y=350, max_width=None, color='black', bidi=True, html=True)
my_canvas.show()

Key clear sentence canvas and music

kb.get_key()
my_canvas.clear()
sound.stop()

Displays Question

if question and not question.isspace():
question = (question + yes_no)
my_canvas_question = canvas(exp)
my_canvas_question.text(question, center=True, x=None, y=None, max_width=None, color='black', bidi=True, html=True)
my_canvas_question.show()
question_response.get_key()
my_canvas_question.clear()
key = question_response.get_key()
# 1 is correct response and 2 is wrong not working properly
if correct_answer in key:
ParticipantResponse = 1
elif correct_answer not in key:
ParticipantResponse = 2
else:
ParticipantResponse = 0
exp.set('ParticipantResponse',ParticipantResponse)

exp.pygaze_eyetracker.log('ParticipantResponse ' +str(ParticipantResponse))

have this in the prepare script

kb = keyboard(exp,keylist= ['space'],timeout = 27000)
question_response = keyboard(exp,keylist= ['y','n'],timeout = 27000)
if answer == 1:
correct_answer = 'y'
else:
correct_answer = 'n'

Comments

  • edited 5:23PM

    Hi OlaNordrum,
    it would really help us if you could display your code in orderly fashion. Please check the "use Markdown extra syntax" link in the tips section. Basically, it you put 4 spaces in front of your code, or enclose your code blocks in three ` characters (so before and after the code block), this should be taken care of.

    Buy Me A Coffee

  • edited 5:23PM

    Hi,

    Do I understand correctly, the first time you are calling kb.get_key(), does work (so, it proceeds to my.canvas.clear()right away), but the second time with `question_response.get_key(), it needs two keypresses?

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.