# TextBox (Beta) not displaying stimuli centred

**URL:** <https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195>\
**Category:** Builder\
**Tags:** textbox\
**Created:** [July 23, 2021, 5:28am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195 "2021-07-23T05:28:29Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [July 23, 2021, 5:28am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/1 "2021-07-23T05:28:29Z")

</div>

OS Win10  
PsychoPy version v. 2021 1.4

What are you trying to achieve?:

I have a simple experiment that displays words (in Thai) as stimuli in the middle of the screen. Ss then rate the words on a scale according to the dimension of interest. Everything was fine with the text component but it wouldn’t work with the Thai script. I changed to the TextBox component and it displays Thai script fine (with the appropriate font) but I cannot for the life of me get the stimulus to display in the centre of the screen.

What did you try to make it work?:

I’ve tried multiple settings in builder view. I’ve also tried using `HorzAlign` and `HorzJust` as code components but these don’t appear to do anything (the stimulus is presented in the centre of the screen but justified left; the first letter is the anchoring point from what I can tell).

It’s not a huge deal as such but when longer letter strings are presented it looks particularly awkward. I’ve attached a couple of screen shots showing the issue.

I hope there’s a solution to this. I’m quite a beginner so may be overlooking something of course.

Thanks in advance,

Ben

This is the code that shows the settings (automatically generated not written by me):

# Initialize components for Routine “exptT”

exptTClock = core.Clock()  
item = visual.TextBox2(  
win, text=‘’, font=‘Sarabun’,  
pos=[0.35, -0.3], letterHeight=0.06,  
size=[1, 1], borderWidth=2.0,  
color=‘white’, colorSpace=‘rgb’,  
opacity=None,  
bold=False, italic=False,  
lineSpacing=1.0,  
padding=None,  
anchor=‘center’,  
fillColor=None, borderColor=None,  
flipHoriz=False, flipVert=False,  
editable=False,  
name=‘item’,  
autoLog=True,

 ![1](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/0/e/0e07404fbc1c6757acd5b2b93c3f85c04b1d1016.png)  
 ![2](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/0/f/0f5fb6a6d7bc880944bd59c06371557bbc0744f7.png)

---

<div class="post-metadata">

**Author:** ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)\
**Post date:** [July 23, 2021, 8:28am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/2 "2021-07-23T08:28:32Z")

</div>

Unfortunately this is a known issue that we’re working on, it’s actually one of the requirements we’ve set ourselves before removing the “beta” sticker from Textbox!

---

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [July 24, 2021, 6:45am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/3 "2021-07-24T06:45:56Z")

</div>

Oh no! There’s no way around it then. I cannot use regular text components because they will not show the Thai script.

Thanks for letting me know, anyway.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [July 25, 2021, 8:44am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/4 "2021-07-25T08:44:20Z")

</div>

I haven’t had a problem displaying Thai script in 2020.2.10 text components

 ![thai](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/a/3/a3db313a3f3867d2488d61575c169c4aa2dcb975.jpeg)

Select language = t  
[https://run.pavlovia.org/jasonludington/miming/html](https://run.pavlovia.org/jasonludington/miming/html)

---

<div class="post-metadata">

**Author:** ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)\
**Post date:** [July 25, 2021, 1:30pm UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/5 "2021-07-25T13:30:24Z")

</div>

Are the characters showing up as squares? If so it’s most likely the font - if memory serves the default font for text components is either Arial or Open Sans, which may not have glyphs for Thai characters. Try changing the font to one of these:

> **[Google Fonts](https://fonts.google.com/?subset=thai)**
>
> Making the web more beautiful, fast, and open through great typography

---

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [July 27, 2021, 9:53am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/6 "2021-07-27T09:53:44Z")

</div>

Oh interesting. Actually, this is from a project that my collaborator (Jason Ludington) and I were working on. You must have been the coder?

It won’t run Thai script in 2021 1.4. I’ve also tried changing the PsychoPy version in the experiment settings. I get this issue even when trying to present Thai text in a text component.

File “C:\Program Files\PsychoPy3\lib\site-packages\pyglet\text\layout.py”, line 942, in \_get\_lines  
glyphs = self.\_get\_glyphs()  
File “C:\Program Files\PsychoPy3\lib\site-packages\pyglet\text\layout.py”, line 1085, in \_get\_glyphs  
glyphs.extend(font.get\_glyphs(text[start:end]))  
File “C:\Program Files\PsychoPy3\lib\site-packages\pyglet\font\base.py”, line 394, in get\_glyphs  
self.glyphs[c] = glyph\_renderer.render(c)  
File “C:\Program Files\PsychoPy3\lib\site-packages\pyglet\font\win32.py”, line 432, in render  
ord(text), ord(text), byref(abc)):  
TypeError: ord() expected a character, but string of length 3 found

##### Experiment ended.

I can only display Thai using Textbox Beta and then it won’t centre the stimulus properly.

@TParsons - that happened previously but I changed the font as per your previous advice (to Sarabun) and it displays Thai text fine now. The issue with the Textbox component is that I cannot centre the text, which is not great for an experiment involving the presentation of letter strings.

This also means I will have issues presenting instructions in Thai.

So I’m not sure what I can do, if anything? Do I need to downgrade the Psychopy software to an older version? I don’t understand how it would work previously and not now.

Any advice most appreciated.

Thank you

Ben

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [July 27, 2021, 3:06pm UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/7 "2021-07-27T15:06:17Z")

</div>

I’ve just created an instructions only version of @jasonludington’s experiment in 2021.1.4 here:

[https://run.pavlovia.org/Wake/thai-test](https://run.pavlovia.org/Wake/thai-test)

The Thai text is still working for me in Arial.

I wondered whether it was because I was setting the text in code rather than pasting directly into the text component. However, I’ve just tested this – the firs 0.5 seconds is hard coded.

I’ll share the repro with you so you can take a look (if you let me know your Gitlab username)

Best wishes,

Wakefield

---

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [July 28, 2021, 2:55am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/8 "2021-07-28T02:55:56Z")

</div>

Thanks, the instruction only test is in English though? I’m trying to display different words in Thai on separate trials but I think the same issue arises whether you use a variable or just paste in the Thai text into a text component.

My workaround has been to use a textbox but that leads me to not being able to centre the text. Appreciate your help, my Gitlab username is: TUPS-lab

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [July 28, 2021, 7:45am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/9 "2021-07-28T07:45:09Z")

</div>

In the initial screen put t as the language instead of e

---

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [July 28, 2021, 11:13am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/10 "2021-07-28T11:13:53Z")

</div>

Thanks, that all works and displays Thai without issue in your program.

Looking forwards to seeing your solution if you can share it.

Best wishes,  
Ben

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [July 28, 2021, 11:16am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/11 "2021-07-28T11:16:37Z")

</div>

> [@bornslippy](#):
>
> TUPS-lab

There’s no such Gitlab user so I shared it with TUPS.

---

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [July 28, 2021, 2:05pm UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/12 "2021-07-28T14:05:44Z")

</div>

Thanks I was in Gitlab rather than [Gitlab.pavlovia.org](http://Gitlab.pavlovia.org). It’s a bit new to me and I hadn’t realised there was a difference.

But, anyway, thanks for the files. I’ll take a closer look tomorrow and see how things are operating.

---

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [July 28, 2021, 2:25pm UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/13 "2021-07-28T14:25:01Z")

</div>

Interesting, so when I run the experiment on my machine (as a standalone psychopy expt) I get the same rendering error code! But it seems to work fine in online format i.e. the link you sent before.

---

<div class="post-metadata">

**Author:** ![Becca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/becca/32/34260_2.png) [@Becca](https://discourse.psychopy.org/u/Becca)\
**Post date:** [March 30, 2022, 11:13am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/14 "2022-03-30T11:13:31Z")

</div>

Hi There,

Just checking - is the issue that you would like this to work locally or online?

For myself in the most recent release this works locally as expected (with central thai text) in version 2022.1.2 on a Windows 10. Files attached.

Thanks!  
Becca  
[thai\_textbox.psyexp](https://discourse.psychopy.org/uploads/short-url/cuMhGLJkvCMqM23343bHeYz6gdg.psyexp) (9.3 KB)  
[words.xlsx](https://discourse.psychopy.org/uploads/short-url/2I8LMNf6kdtSgwG6yiHi8TF0XGF.xlsx) (18.0 KB)

---

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [March 30, 2022, 12:16pm UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/15 "2022-03-30T12:16:12Z")

</div>

Hi Rebecca,

It’s for online yes. I’ve not actually checked offline as I really need to collect data online.

Best wishes

Ben

---

<div class="post-metadata">

**Author:** ![bornslippy](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bornslippy](https://discourse.psychopy.org/u/bornslippy)\
**Post date:** [April 1, 2022, 8:46am UTC](https://discourse.psychopy.org/t/textbox-beta-not-displaying-stimuli-centred/24195/16 "2022-04-01T08:46:35Z")

</div>

Hi Becca,

I just tried your experiment and it does work. This may be because of updates to PsychoPy regarding textboxes. When I initially set up the experiment I was using English words then got into problems when I switched to Thai. Then I resorted to the Beta text box and had the issues with centring. I wonder if I can switch back to regular textboxes and whether this will work in the online format?

I’m running everything online rather than offline now.

Best wishes,

Ben
