Chatbox

Hello I’ve been trying to use DirectEntry to create a chatbox, but I can’t seem to move the text from starting at the center of the screen. Can anyone help me with this?

Here is the code:

import direct.directbase.DirectStart
from direct.task import Task
from direct.actor import Actor
import math

from direct.directbase.DirectStart import *
from pandac.PandaModules import *
from direct.gui.DirectGui import *

#Load the first environment model
environ = loader.loadModel(“models/environment”)
environ.reparentTo(render)
environ.setScale(0.1,0.1,0.1)
environ.setPos(-8,42,0)

#Task to move the camera
def SpinCameraTask(task):
base.camera.setPos(0,0,1)
base.camera.setHpr(15, 0, 0)
return Task.cont

taskMgr.add(SpinCameraTask, “SpinCameraTask”)

def handleCommand(value):
print “value = %s” % (value)

entry = DirectEntry(width = 10,
numLines = 3,
scale = 0.1,
relief = GROOVE,
cursorKeys = 1,
frameSize = (3, 12, -3.5, -8),
frameColor = (225, 126, 54, 0.3))

entry2 = DirectScrolledFrame(frameSize = (3, 12, 7, -3),
scale = 0.1,
relief = GROOVE,
frameColor = (225, 126, 54, 0.3),
canvasSize = (3, 12, 5, -3),
autoHideScrollBars = “TRUE” )

frame = DirectFrame(scale = 0.1,
relief = GROOVE,
frameSize = (3, 12, -3.5, -8),
frameColor = (225, 126, 54, 0.3))

run()

Specify pos = (0.5, 0.2) or some similar position roughly in the range (-1.333 … 1.333, -1.0 … 1.0) to move your DirectGui elements around on the screen.

But you may also want to specify parent = entry2 for the DirectEntry, if your intention is to put it within the DirectScrolledFrame.

David