There are code examples in the Panda GUI manual. However, too many arguments make the code cumbersome and unreadable. I would like to discuss the external code style for such cases.
I suggest we do it this way:
textObject = OnscreenText(
text="This is my Demo",
pos=(0.95, -0.95),
scale=0.07,
fg=(1, 0.5, 0.5, 1),
align=TextNode.ACenter,
mayChange=1
)
Or:
textObject = OnscreenText(mayChange=1)
textObject.setText("This is my Demo")
textObject.setPos(0.95, -0.95)
textObject.setScale(0.07)
textObject.setFg((1, 0.5, 0.5, 1))
textObject.setAlign(TextNode.ACenter)
The second method is also a way to get to know the API.
At the moment the original looks like this:
bk_text = "This is my Demo"
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)
Which looks neat to me, but it’s not very informative or structured.