Hi,
I’m trying to permanently place an OnscreenText top left of the window.
As can be seen with the example, the text is not correctly placed, the top red border should be visible like the left one.
Unfortunately I can’t figure out how to correct this.
Maybe someone can help me with this problem.
Below is the test code
Greetings
Revington
import direct.directbase.DirectStart
from direct.gui import OnscreenText
from direct.showbase.DirectObject import DirectObject
from panda3d.core import TextNode
class evtHandler(DirectObject):
def onAspChanged(self):
textObject.setPos(base.a2dLeft, base.a2dTop)
bk_text = "This is my Demo"
textObject = OnscreenText.OnscreenText(
text = bk_text,
scale = 0.10,
fg=(0,0.0,0.0,1),
bg=(0,0.5,1.0,1),
align=TextNode.ALeft,
frame=(1,0,0,1),
parent=aspect2d,
mayChange=1)
textObject.textNode.setFrameAsMargin(0,0,0,0)
textObject.textNode.setCardAsMargin(0,0,0,0)
if __name__ == "__main__":
evt = evtHandler()
evt.accept("aspectRatioChanged", evt.onAspChanged)
run()