What I’m trying to do:
- Create a DirectFrame to frame an image for a GUI element
- Have the image actually bounded by the parent frame
from sys import path from os.path import abspath as directory from panda3d.core import Filename from direct.showbase.ShowBase import ShowBase from direct.gui.DirectGui import DirectFrame class Base(ShowBase): def __init__(self): ShowBase.__init__(self) #convenience for grabbing resources self.dir = Filename.fromOsSpecific(directory(path)).getFullpath() #brown outer container filling most of the screen self.container = DirectFrame(frameColor=(.256,.128,0,1), frameSize=(-.9,.9,-.9,.9)) #frame for to contain the image self.frame = DirectFrame(frameColor=(.9,.9,.9,1), frameSize=(-.1,.1,-.1,.1), pos=(0,0,0), image=self.dir+"/resources/image.png") if __name__ == '__main__': game = Base() game.run()
What I’m getting:
image.png fills the entire screen
if I remove “image=self.dir+”/resources/image.png" from the parameters there is an appropriately-sized off-white frame.
What confounds me:
Creating the frame gives it the appropriate size.
Giving the frame a background image causes the background image to cover the entire screen
The same occurs if I use an OnscreenImage and reparent it to the frame
I’m at my wits end. There’s gotta be something stupid I’m doing, but the documentation is so thin, and says that child elements have properties relative to their parent, so at the very least reparenting an OnscreenImage should scale to the frame.
What’s even weirder is that if I use an Onscreen Image as the parent, instead of a frame, then another onscreen image as the child, I actually get the result I want, but without frame functionality.
What am I doing wrong?