functions in checkbox
in OpenSesame
Is it possible to change the text_color
in a checkbox item?
Or is it possible to log something different from the content of the text in the checkbox?
My text is quite long. I'd prefer to log numbers for the different options in the group (as almost always in groups).
I now made a workaround, by putting numbers in the text of the checkboxes and the real text into a labels.
It would be nice to set the numbers 'white'
, so you don't see them anymore.
Here is my code.
var.Phase='education'
var.Stim='edu'
def edu_val():
"""Checks whether at least one field has been filled out"""
return var.Resp in [1,2,3,4,5,6]
edu = Form(validator=edu_val, cols=[4,1,12,4], rows=[3,1,1,1,1,1,1,1,1,3], spacing=10, margins=(100, 100, 100, 100))
labelx = Label(text=u'Höchster Bildungsabschluss', frame=False, center=False)
label1 = Label(text=u'Pflichtschule', center=False)
label2 = Label(text=u'Sekundärabschluss (mittlere Reife)', center=False)
label3 = Label(text=u'Sekundärabschluss (Lehre)', center=False)
label4 = Label(text=u'Sekundärabschluss (Matura/Abitur)', center=False)
label5 = Label(text=u'Tertiärabschluss (Akademie/Kolleg)', center=False)
label6 = Label(text=u'Tertiärabschluss (Universität/Hochschule)', center=False)
checkbox1 = Checkbox(text='1', group='education', var='Resp')
checkbox2 = Checkbox(text='2', group='education', var='Resp')
checkbox3 = Checkbox(text='3', group='education', var='Resp')
checkbox4 = Checkbox(text='4', group='education', var='Resp')
checkbox5 = Checkbox(text='5', group='education', var='Resp')
checkbox6 = Checkbox(text='6', group='education', var='Resp')
button = Button(text='Ok', frame=True, center=True)
edu.set_widget(labelx , (2, 1))
edu.set_widget(checkbox1, (1, 2))
edu.set_widget(checkbox2, (1, 3))
edu.set_widget(checkbox3, (1, 4))
edu.set_widget(checkbox4, (1, 5))
edu.set_widget(checkbox5, (1, 6))
edu.set_widget(checkbox6, (1, 7))
edu.set_widget(label1 , (2, 2))
edu.set_widget(label2 , (2, 3))
edu.set_widget(label3 , (2, 4))
edu.set_widget(label4 , (2, 5))
edu.set_widget(label5 , (2, 6))
edu.set_widget(label6 , (2, 7))
edu.set_widget(button , (2, 8))
edu._exec()
Comments
Yes, that's quite easy because you can use
css
styling, like so:Not really, although you can monkey-patch the
CheckBox
widget, such as with the code below. (Personally, I think your solution of using numbers as the checkbox text is quite ok, though.)Check out SigmundAI.eu for our OpenSesame AI assistant!
Thank you for that solution. If you change the color, my workaround does not work anymore, because it logs var.Resp= 5
So i used your monkey-patch.
Maybe it helps someone else who wants to assess educational levels.