If i’m not mistaken, you need something like this :
# pos is the 3D position of the target
# frame is the GUI widget
# the screen position is given by a2d
p3 = base.cam.getRelativePoint(render, Point3(pos))
p2 = Point2()
if base.camLens.project(p3, p2):
r2d = Point3(p2[0], 0, p2[1])
a2d = aspect2d.getRelativePoint(render2d, r2d)
frame.setPos(a2d)