Destroying a node from a nodepath reference

Hi have the following code in my aplication:

               if world.TopGui.find("**/=Cwin"):
                        OldCwin = world.TopGui.find("**/=Cwin")
                        OldCwinNode = OldCwin.node()
                        print OldCwinNode

world.TopGui is a nodepath which “points” to the main gui frame.

I search for a children (a directFrame object) tagged with Cwin to destroy it. But it fails.

print OldCwinNode shows

PGItem DirectFrame-pg11 [Cwin] T:(pos -0.8 0 -0.2)

And the error i get is:

AttributeError: 'libpanda.PGItem' object has no attribute 'destroy'

How should I destroy the directFrame children objetc ?


The same way you would “destroy” any node; detach it from the parent node and make sure you aren’t holding any references to it.