I seem to have hit a bit of an odd problem:
I’m attempting to create a blank OnscreenImage – that is to say, one that has no image at all. From what I’ve seen in the documentation, it should be perfectly valid to construct one without the “image” parameter and to then assign an image at a later point via “setImage”.
I’m currently doing something like this:
self.mapBackdrop = OnscreenImage(parent=self.handleNode)
Unfortunately, I seem to be getting the following error on the second line above:
If I comment out the “setBin” line above I seem to just get a similar error at a later point, with a later attempt at using the “self.mapBackdrop” object.
Am I doing something incorrectly? Is this a bug? Is there something that I might do to fix this?
My thanks for help given!
The error indicates that the NodePath is empty, id est, not pointing to any PandaNode, and therefore operations such as setBin are invalid.
Perhaps you could simply pass Texture() as image in the constructor.
Indeed, an OnscreenImage that has no image also has no node, so you can’t call setBin() on it. But you could call setBin() on a parent. Try just using self.handleNode.setBin() instead. If you have other children of handleNode that you don’t want to inherit this property, then create a parent node specifically for your image.
Ah, fair enough, and thank you both.
This behaviour might be worth clarifying in the manual, I think, since I got the impression there that I should be getting a perfectly valid (if geom-less) NodePath when I constructed an “empty” OnscreenImage.
(I take it that the manual is no longer freely editable? I just took another look at the page regarding OnscreenImage, and don’t seem to have found the control that I vaguely recall being once present that allowed one to edit a page.)
You should have a response.