Here’s my today’s problem: I usually create my classes on a NodePath.
self.myText= OnscreenText(text = '123456',scale = 0.05,pos=(0,0))
I just figured out that it’s not working as I aspected it to work when reparenting directGui elements to other NodePath.
self.myFrame1 = DirectFrame(frameColor=(.7,0.7,0.7,1),pos=(0,0,0),
There will be no error with the code above but the text will not render.
I figured out that the text is not appearing because I’m repareting a Gui element to a NodePath which I reparent to a Gui.
Well, to avoid this, I suppose I just need to replace NodePath by the correct father but what’s the father of directGui objects ?
I thought it was render2d but it’s not working!
The normal parent is aspect2d. But I don’t see you assigning MyObj to any parent at all.
Woops! You’re right! Typed the exemple too quickly!
Just corrected it.
What I’m looking for is the father class:
So, you want to subclass from DirectGui and make your own kind of object? You can subclass from any of the existing DirectGui classes, for instance DirectFrame, which is probably the minimal functionality. Note that you also have to call initialiseoptions() when you do this. See discourse.panda3d.org/viewtopic.php?t=2495 .
DirectFrame it was
So now, I can create my own type of button, frames etc… Amazing!
I tried with and without initialiseoptions() and both did work. For this, I’ll blindly trust you and always put it in the declarations but this brings the following:
If in a near futur, I’ll need to create a class from an other object. How can I know if there is a function that I’m suppose to call additionnaly to init ?
And one last question:
Is it possible to generate an event when the mouse rollover a button ?
I tried to replace the text “rolling over” by a function that perform my desired actions and then return a string but KO!
Thx in advance
You have to read the documentation for the class you’re inheriting from. Usually, you don’t need to do anything special; the DirectGui classes are unusual in this requirement.