'OnScreenText' not defined

Whenever I execute my file I get the error:

global name ‘OnScreenText’ is not defined.

Did I do something wrong? My code is…

import direct.directbase.DirectStart
from pandac.PandaModules import CollisionTraverser,CollisionNode
from pandac.PandaModules import CollisionHandlerQueue,CollisionRay
from pandac.PandaModules import Filename
from pandac.PandaModules import PandaNode,NodePath,Camera,TextNode
from pandac.PandaModules import Vec3,Vec4,BitMask32
from direct.gui.OnscreenText import OnscreenText
from direct.actor.Actor import Actor
from direct.task.Task import Task
from direct.showbase.DirectObject import DirectObject
import random, sys, os, math

def textTitle(msg):
	return OnScreenText(text=msg, style=1, fg=(1,1,1,1),
			pos=(1.3, -.95), align=TextNode.ALeft, scale = .05)

def textHelp(y, text):
	return OnScreenText(text=text, style=1, fg=(1,1,1,1),
			pos=(-1.3, y), align=textNode.ALeft, scale = .05)
class World():
	def __init__(self):
		self.title = textTitle("Test")
w = World()

btw… I took some code off roaming Ralph.

Thank you.

As you can see from the import statement in your own code:

from direct.gui.OnscreenText import OnscreenText

The name is “OnscreenText”, not “OnScreenText”.


Oh thanks! :smiley:

BTW: That’s kind of weird because I got that code off Roaming Ralph and It works there.