| Reference | Downloads | Github

Form Component "Unbound Local Error"

What are you trying to achieve?:
I’m trying to insert a questionnaire into my study to measure dietary restraint.

What did you try to make it work?:
I followed the instructions here: Form Component — PsychoPy v2021.2 and included all elements in the csv file.

What specifically went wrong when you tried that?:
return respHeight /[1] + self.itemPadding
UnboundLocalError: local variable ‘respHeight’ referenced before assignment

From a quick google search this does seem to be a common coding error but I couldn’t find any record of anyone having this problem in builder.

RestraintScale.csv (1.2 KB) RestraintScale.psyexp (3.7 KB)

Hi @jemmasedgmond, this was an error with the layout value, which was horizontal rather than horiz. Attached is the fixed Form, and I reformatted it a bit to make the items more readable (changes response width, and item padding).

RestraintScale.csv (1.2 KB) RestraintScale.psyexp (3.7 KB)

1 Like

Thanks so much @dvbridges - that’s brilliant!