The problem of inputting Chinese characters when using textbox

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 22.2.1

I want to use the textbox to input Chinese characters (which are a composition of two or more letters, and every composed string can refer to any of four or more different characters, which people need to disambiguate by choosing which one is the intended one), but the extra layer of inputting Chinese character is not displayed, although I can choose 1 answer. I looked through previous posts and a solution is using dialogue boxes ( Text responses in python: Input() function and dialogue boxes - #3 by miguel_santin ) . But that doesn’t work very well.
So, is there any way I can input Chinese with the extra layer like the figure?

image

I’m not very familiar with how typing Chinese characters works, is the box in the screenshot a part of the textbox in the software you’re using or is it something put on the screen by a third party typing software?

The screenshot shows the scene of inputting Chinese characters by a third party typing software, and I want to achieve it in the PsychoPy. The textbox now supports Chinese input, but does not show the extra layer of choosing the right characters that you want to use. As shown in the screenshot, I want to input ‘谢谢’, which mean ‘thanks’, so I need to choose the first answer after I inputted ‘xiexie’, which is the pronunciation of '谢谢‘ ( like the relation of ‘/θæŋks/’ and ‘thanks’). The result of lack of the extra layer is that people couldn’t choose what they want to type correctly.

Ah I see, that makes sense as the PsychoPy :textbox: Textbox component isn’t the same as a textbox on a website or software interface - so your software won’t recognise it as a text input.

There’s probably a Python package out there which can handle the conversion from ‘xiexie’ to ‘谢谢’, so it’s plausible that you could use :button: Button components or maybe a :slider: Slider component to simulate this functionality within an experiment… I’ll look for a suitable package and let you know!

It’s also worth checking pavlovia.org, it’s entirely possible that a member of the community has already made something like this!

I have something which gets some of the way there; the package dragonmapper allows translation from pinyin to zhuyin, but I’ve not been able to find anything to do pinyin/zhuyin to hanzi. With the help of @suelynnmah I’ve put together a quick demo to show how to implement this within an experiment:

(I made it public so you should be able to find it in the :pavlovia_search: search dialog in Builder and create your own fork, or you can always just click View Code and download the psyexp file)

To run it you need to follow these steps:
https://www.psychopy.org/recipes/addCustomModules.html
to install the dragonmapper package, and if you can find a Python package with a straightforward pinyin → hanzi function then you can install that via the same process and replace the calls to dragonmapper in the example, I just couldn’t find anything with my limited knowledge of how the various Chinese scripts work.

1 Like

Thank you very much for your help. I’ll try it right away.

可以在psychopy里面添加一个easygui扩展包,然后输入汉字时让弹窗奔出来。可以做到类似于eprime中(inputbox)的效果。

1 Like

You can use easygui package.
http://easygui.sourceforge.net/

1 Like

好的,谢谢!!!我尝试一下

do you have a sample script that you can share? I’m struggling with this issue too.

1.visit easygui homepage-download
2.open psychopy-path-add easygui
3.befor experiment-import easygui
4.set fullscreen=false
4.befor routine-a=easygui.textbox(‘当前是一个文本输入框,请编辑出您最喜欢的是哪位?’,‘非一般问卷调查’)
5. adddata(a)

:rofl:或者你留个邮箱,我发个demo给你

2 Likes

hybpsy2018@163.com

Hi Weixing,

I’m struggling with the same issue with Chinese typed response in Psychopy. Can you share the demo with me please? Thank you!

留个邮箱给我,我发给你
或者你直接联系我的邮箱weixinghhu@163.com

tzxlyf@163.com
非常感谢!

Hi- I met the same problem- Could you please send the demo to my email address (hopefully as soon as you can - thank you): travel1993@163.com
Thank you.

demo我没保存,你可以加我微信或者给我发邮件我告诉你步骤
weixinghhu@163.com,微信已经发你邮箱了

你好,请问你这个问题解决了吗,是通过easygui解决的吗?

Hello, it seems that the public code for this Paviovia is invalid. Clicking on it does not include the psyexp file. If it’s convenient for you, could you please upload it again? Thank you。