如何在Pygame中启用中文输入?
我想做的是:在PyGame中使用 Pinyin输入方法 中文字符。
我想出的唯一方法是:阅读单个键盘输入,然后使用一些图书馆,例如pinyin2hanzi
将字母字符串转换为可能的汉字列表,就像Rockstar的方式一样在RDR2中处理中国的输入。下面提供了此当前解决方案的一个示例:
问题是,问题是,这与一个人的惯例输入方式完全不同中文。通常,当我们使用拼音输入方法输入中文时,可用选项由输入方法本身列出,如下:
因此,另一种描述我问题的方式可能是:我如何启用Pygame中的Pinyin输入方法并阅读中文我决定输入构成拼音的英语字符的组合而不是输入?
What I want to do is this: using pinyin input method to input Chinese characters in pygame.
The only way to do this I have figured out is: reading the individual keyboard input, and then use some libraries like Pinyin2Hanzi
to convert the strings of letters into a list of possible Chinese characters, quite like how RockStar deals with Chinese input in RDR2. An example of this current solution is provided below:
The problem is, this is entirely different from one's usual way of inputing Chinese characters. Normally, when we input Chinese using the pinyin input method, the available options is listed by the input method itself, like below:
So, one other way of describing my question can be: how do I enable the pinyin input method in pygame and reading the Chinese character I decide to input rather than the combination of English characters that constitute its pinyin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这种IME的东西不是我的茶杯,但我已经做了一些研究,我得到了您。
这是Pygame示例“ TextInput.py”的修改版本,其补丁使候选窗口打开。我已经在Github上将补丁提交给Pygame。您还应该使用最新的Pygame副本,您可以动手取得最佳效果。我不认为2.1.2会为此工作。运行
PIP安装PyGame -Upgrade -Pre
。- Pre
为您提供最新的预发行版本。抱歉,它已经漫长了,但是希望这对您有所帮助。
This IME stuff is not my cup of tea, but I've done some research and I've got you.
This is a modified version of pygame's example "textinput.py", with a patch that makes the candidate window open. I've submitted the patch to pygame on Github. You should also use the latest copy of pygame you can get your hands on for best results. I don't believe 2.1.2 will work for this. Run
pip install pygame --upgrade --pre
. The--pre
gets you the latest pre release version.Sorry it's so long winded, but hopefully this helps you out.