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

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