I have a question which is related to a previous topic I opened (obtain written text in Japanese).
Now, I have trouble with succesfully presenting different Japanese characters when reading from an excel file (Im attaching a relevant file). It just displays empty characters, instead of Japanese characters…
This is a tricky one to do with whether the font used in the forms supports the character type. Unfortunately there is no font parameter visible in the form component itself, but you can make a form using some custom code and control the font within the code (this uses Armino to render the characters).
Hopefully this helps with what you need to achieve!
BeccaJapaneseForms.psyexp (10.8 KB)
Thank you so much again!
However, could you please also share the my_form_symp_female.csv file with me that the code reads? When I try to save my xlsx file as csv, it automatically changes the Japanese characters to questionmarks (???)…
Insead of reading the csv file, I now read my xlsx file and that works :). So, I succeed to see the Japanese characters inside the form!
However, one more issue. Since its not that clear which item belongs to which yes/no answer-option, I tried to place the items slightly down (more close to the yes/no options). However, I dont succeed… I do succeed to place them more to the left or right.
I guess the part of the code I need to adjust is:
pos=[
item['itemCtrl'].pos[0]+item['itemCtrl'].size[0]/2, # adjust position to account for anchor
item['itemCtrl'].pos[1]
]
If I change the “2” in the first line of code, I can change left/right position of the items.
However, I dont succeed to place the items more up/down when adjusting the 2nd line of code…
I tried many things, but I dont succeed to change the y-location of the items inside the form.
I would like the items to be placed slightly down (closer to the corresponding yes/no options). Or else, its not that clear which item belongs to which yes/no option (please see the image below)…
Is there a way to adjust the form_code to do what I need? …
CODE:
win.allowStencil = True form = visual.Form(win=win, name=‘form’,
** #items=‘my_form_symp_female.csv’,**
** items=‘my_form_symp_female.xlsx’,**
** textHeight=0.02,**
** randomize=False,**
** size=(1.5, .7),**
** pos=(0, 0),**
** style=(‘dark’,),**
** itemPadding=0.07)** #words = 3 # may want this to vary with survey type
for i, item in enumerate(form.items):
** if ‘itemCtrl’ not in item:**
** # Skip if there’s no label**
** continue**
** if not isinstance(item[‘itemCtrl’], visual.TextBox2):**
** # Skip if the label isn’t a TextBox**
** continue**
** # Figure out whether there are any Hebrew characters in the label**
** language = “LTR” # Start out with left-to-right**
** # Create an equivalent TextStim object**
** baseY = item[‘itemCtrl’]._baseY # store Form-specific param**
** form.items[i][‘itemCtrl’] = visual.TextStim(win,**
** text=item[‘itemCtrl’].text, **
** font=“Arimo”, # Arimo is a Google Font which can render other characters**
** pos=[**
** item[‘itemCtrl’].pos[0]+item[‘itemCtrl’].size[0]/2, # adjust position to account for anchor**
** item[‘itemCtrl’].pos[1]**
** ], **
** height=item[‘itemCtrl’].letterHeight,**
** languageStyle=language)**
** form.items[i][‘itemCtrl’]._baseY = baseY**
However, I’m a bit stuck with 1 issue… I also tried to write on the forum.
However, I would like to change the y-location of the items (I only succeed to change their x-location)… Specifically, I would like the items to be placed slightly down (closer to the corresponding yes/no options). Or else, it’s not that clear which item belongs to which yes/no option (please see the image below)…
I guess I need to change this part of the code: pos=[ item[‘itemCtrl’].pos[0]+item[‘itemCtrl’].size[0]/2, item[‘itemCtrl’].pos[1] ]