OnscreenImage problem

Hi all,
What seems to be a really easy operation has gone bad.

I am trying to display a simple image using :
self.menu = OnscreenImage(image = Constants.MYDIR+"/models/cafeScene/menu.jpg", pos = (1,0,0), scale = (0.4,0.4,0.4))

I have added:
from direct.gui.OnscreenImage import OnscreenImage

However the error I receive is as under:
TypeError: NodePath::set_texture() argument 1 must be Texture, not NoneType

I have tried using both .png and .jpg files.
Please suggest what might be the problem.

Thanks & Regards,
Dev.

Maybe you didn’t specify MYDIR?

import sys, os
from pandac.PandaModules import Filename
MYDIR = os.path.abspath(sys.path[0])
MYDIR = Filename.fromOsSpecific(MYDIR).getFullpath()
imageFile = MYDIR+"/models/cafeScene/menu.jpg"
self.menu = OnscreenImage(image = imageFile, pos = (1,0,0), scale = (0.4,0.4,0.4))

Hello birukoff,
Thank u for ur reply. I have specified MYDIR. Still doesn’t work :frowning:

Regards,
Dev.

If you print MYDIR just before creating the OnscreenImage, what does it produce? I’m wondering whether something hasn’t gone wrong there somewhere along the line, despite it having been set at some point…

Hello Thaumaturge,
Yes, I found the MYDIR to be incomplete!. It now works. Thank you.

Regards,
Devang.

It’s my pleasure - I’m glad that you found the problem. :slight_smile: