Hiding DirectGui object

Hi there,

this might seem like a very stupid question, but unless i’m completely blind i cannot find an answer. When using DirectGui objects, how do you hide / show them? i tried parenting them to a PandaNode and then attaching that to the render2d, but this completely distorts the gui and the DirectEntry doesn’t work anymore. Any ideas?

Functions with the same name as for NodePath.

from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import DirectButton

class Test(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        base.accept("h", self.hide)
        base.accept("s", self.show)

        self.button = DirectButton(text=("OK", "click!", "rolling over", "disabled"), 
                                   scale = 0.1)

    def hide(self):
        self.button.hide()

    def show(self):
        self.button.show()

test = Test()
test.run()

For the simple reason, let me note, that they are NodePaths. (They inherit, amongst other things, from NodePath, and they’re present within the scene-graph just as normal NodePaths are.)

As a result, they can be treated as NodePaths: You can set their position, rotation, and scale; you can hide and show them; you can apply shaders to them; and so on and so forth. Indeed, while I think that the built-in mouse-functionality (i.e. clicking on buttons, etc.) will stop working if you do the following, you can nevertheless even attach them to geometry in the 3D world if you want, I do believe.