OnscreenText Placement

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()

Set the parent to base.a2dTopLeft, it will stick like glue to that corrner even if you resize the window.

You will need to set the frame to something like 0, -1, 0, -1 to keep it on screen (a2dTopLeft has its 0,0 point in the top left).

or you can just use my module for easy alignment :
[DirectGUI or nodepath alignment)