Howdy, Stranger!

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

Supported by

[solved] Problem saving vars

edited December 2015 in OpenSesame

Hi! I'm using the form_widget in the inline script. But I found some troubles.

If I do var.q1 = q1 the result that is stored is : <libopensesame.widgets._label.label object at 0x7fb23dc22f50>

What is happening? If I don't do the var.q1 = q1, the response is not stored.

# create the widget
form = widgets.form(exp, rows = [2,2,2,2,2], cols = [1],theme='plain')

#quiestions
q4 = widgets.label(form, text ="¿Con qué frecuencia miras reproducciones de obras de arte visual en internet?")
q5 = widgets.label(form, text = "¿Con qué frecuencia hablas de arte visual con tus amigos o familia? ")
# put the questions on the form
form.set_widget(q4, (0,0))
form.set_widget(q5, (2,0))

# set the responses
r4 = widgets.rating_scale(form, nodes=["Nunca", "Una vez al año", "Dos veces al año", "Una vez cada tres meses", "Una vez al mes", "Una vez cada dos semanas", "Una vez cada semana"], var='q4')
r5 = widgets.rating_scale(form, nodes=["Nunca", "Una vez al año", "Dos veces al año", "Una vez cada tres meses", "Una vez al mes", "Una vez cada dos semanas", "Una vez cada semana"], var='q5')

# put the responses on the form 
form.set_widget(r4, (1,0))
form.set_widget(r5, (3,0))
# put a next button 
nextButton = widgets.button(form, text='Siguiente')
form.set_widget(nextButton, (4,0))
# exec!
form._exec()


var.q4=q4
var.q5=q5

Comments

  • edited 1:25AM

    Hi Guido,

    If you pass the var keyword to widgets, like you're doing with the rating_scale, the response will be stored in an experimental variable. See also:

    So you're doing it well, to paraphrase LL Cool J.

    The reason that these variables aren't logged automatically, is that OpenSesame isn't aware of their existence. (Assuming that the logger is first called before the form is executed. Is that right?) To work around this, you can simply add q4 and q5 as as custom variables to the logger item.

    Note that what you're doing here:

    var.q4=q4
    var.q5=q5
    

    ... is assigning the widget objects themselves—not their response values—to experimental variables. But adding these lines to the inline_script does make OpenSesame (which uses some limited introspection) aware that these variables exist. This is why they are logged, but don't have the response values. Does that make sense?

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited 1:25AM

    At first I was: image

    But then I read carefully : ) My problem was solved putting this in the logger
    set auto_log "yes"
    log q1
    log q2
    ...

    Thank you!

  • edited 1:25AM

    That meme is actual footage of me developing OpenSesame.

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

Sign In or Register to comment.