Hello,I’m using DirectEntry in my code,but it does not work when input Chinese characters.
I need some help to fixed this.
Already set “text-use-harfbuzz true” in the Config.prc file which in the setup folder/ect.
Here is my code below.
import direct.directbase.DirectStart
from direct.gui.OnscreenText import OnscreenText
from direct.gui.DirectGui import *
from panda3d.core import *
#add some text,want to display some Hanzi content
bk_text = “这是我的Demo” #displaying Hanzi, works
font = loader.loadFont(“zkwy.ttf”)#load target Hanzi font
textObject = OnscreenText(text=bk_text, pos=(0.95, -0.95), scale=0.07,
fg=(1, 0.5, 0.5, 1), align=TextNode.ACenter,
mayChange=1)
textObject.setFont(font)#set target Hanzi font
#callback function to set text
def setText(textEntered):
print(“text entered”)
textObject.setText(textEntered)
#add text entry
entry = DirectEntry(text = “”, scale=.05, command=setText,
initialText=“输入Something”, numLines = 2, focus=1,
entryFont=font)#set entryFont to enable display Chinese Hanzi
#run the tutorial
base.run()
When runs the code, it can display the Chinese Character Hanzi content in both OnscreenText and DirectEntry, But just can’t input Chinese Hanzi content.
Here is the detailed program behavior when trying to input Hanzi.
The IME works when try to input Hanzi. After finish Hanzi content input, there appears a widget with a green arrow on it. It maybe some widget works together with IME, But the Chinese characters can’t put into the entry.
It seems that, the Panda3d widget can’t get content from IME, or can’t update its appearance after got Hanzi content.
The following is the developing environment Information.
Windows 11
Python 3.12.2
Panda3D-SDK-1.10.15-x64
IME Sogou, download link, https://shurufa.sogou.com/
Please help,thanks a lot.