[solved] Problem saving vars
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
Hi Guido,
If you pass the
var
keyword to widgets, like you're doing with therating_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 addq4
andq5
as as custom variables to the logger item.Note that what you're doing here:
... 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
Check out SigmundAI.eu for our OpenSesame AI assistant!
At first I was:
But then I read carefully : ) My problem was solved putting this in the logger
set auto_log "yes"
log q1
log q2
...
Thank you!
That meme is actual footage of me developing OpenSesame.
Check out SigmundAI.eu for our OpenSesame AI assistant!