…Panda3D quits abruptly with bad messages on console as follows:
Assertion failed: !is_empty() at line 269 of built/include/nodePath.I
Traceback (most recent call last):
File "x.py", line 36, in <module>
run()
File "linuxroot/usr/share/panda3d/direct/src/showbase/ShowBase.py", line 2266, in run
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 965, in run
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 903, in step
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 802, in __stepThroughList
File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 721, in __executeTask
File "linuxroot/usr/share/panda3d/direct/src/showbase/ShowBase.py", line 1526, in __igLoop
AssertionError: !is_empty() at line 269 of built/include/nodePath.I
creates an empty NodePath. This is a NodePath that has no node whatsoever; it’s like a NULL pointer. It’s completely different from this statement:
denp=NodePath('denp')
which creates a PandaNode named ‘denp’, then wraps a NodePath around it.
The first form will result in an empty NodePath being passed to your TextGraphic, which is illegal; the second form will work correctly.
But you don’t really need an intervening node. You could just pass the DirectEntry itself into the TextGraphic. Use parent = NodePath() when creating the DirectEntry so it doesn’t attach itself to aspect2d by default.
import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.gui.DirectGui import *
import direct.gui.DirectGuiGlobals as DGG
#----
if __name__ == '__main__':
b=DirectButton(
parent=NodePath('butt'),
text=("OK", "click!", "rolling over", "disabled")
)
tpGg1=TextGraphic()
tpGg1.setModel(b)
tb=b.getBounds()
print tb
tpGg1.setFrame(*tb)
#
tpMgr = TextPropertiesManager.getGlobalPtr()
tpMgr.setGraphic("gr1", tpGg1)
#
text=TextNode('tnode')
tn=base.aspect2d.attachNewNode(text)
text.setText("this is a button\n\5gr1\5\5\2")
tn.setScale(.06)
#
run()
but not perfectly cos the text is partially overlapped by the button but this is a very minor issue even if confirms that the text stuff pretty needs a little overhaul.