Help with DirectEntry on osx

Hi!

I have been trying to use DirectEntry in our game so players can enter their username and password before starting the game. I am doing this on a MacBook running osx v.10.4.8.

The frame displays no problem but when I try to input text nothing happens. I have seen another posting from someone with the same problem but no replies.

Does anybody know how to fix this??? (code follows- see ‘def loginScreen’)

Help will be greatly appreciated! Thanks

from pandac.PandaModules import loadPrcFileData  #Modifies/adds the .prc (Panda3D's configuration file) 
#loadPrcFileData("", "client-sleep 0.03")
#loadPrcFileData("", "interpolate-frames 1")

#encoding: UTF-8

import direct.directbase.DirectStart  #starts the Game (opens an empty window)
from pandac.PandaModules import *     #Contains most of Panda's modules
from pandac.PandaModules import Material
from direct.gui.DirectGui  import *   #Imports Gui objects we use for putting text ont the screen
from direct.showbase.DirectObject import DirectObject  #to listen for events
from direct.showbase.ShowBaseGlobal import *
from direct.actor.Actor import Actor   #to use animated actors
from direct.interval.IntervalGlobal import *  #to use intervals
from direct.task import Task  #to use tasks
from direct.distributed.PyDatagram import PyDatagram  #to send data to server
from direct.distributed.PyDatagramIterator import PyDatagramIterator 
import math  #to use math (angles,degrees..etc)
import random
import re
import MySQLdb
import socket
from md5 import md5

#load first environment model
import sys, os

# Function to put instructions on the screen.
def addInstructions(pos, msg):
    return OnscreenText(text=msg, style=1, fg=(1,1,1,1),
			pos=(-1.3, pos), align=TextNode.ALeft, scale = .05)

# Function to put title on the screen.
def addTitle(text):
    return OnscreenText(text=text, style=1, fg=(1,1,1,1),
	                pos=(1.3,-0.95), align=TextNode.ARight, scale = .07)

#Find out what dir this program is in
AppPath = os.path.abspath(sys.path[0])
AppPath = Filename.fromOsSpecific(AppPath).getFullpath()
#print AppPath

curposindex =[]

class World(DirectObject):                          #our main class

    def __init__(self):               #iniialization method caused when a world object is created
    
	# Post instructions on screen
	self.title = addTitle("Psychology Dept. Glasgow")
	self.inst1 = addInstructions(0.95, "[ESC]: Quit")
	self.inst2 = addInstructions(0.90, "[Left Arrow]: Turn camera left")
       	self.inst3 = addInstructions(0.85, "[Right Arrow]: Turn camera right")
	self.inst4 = addInstructions(0.75, "[O]: Move camera forwards")
	self.inst5 = addInstructions(0.70, "[L]: Move camera backwards")
        #make background color black (R=0, B=0, G=0) intead of default grey
	base.setBackgroundColor(0, 0, 1)
	base.disableMouse()
	self.speed = .10 # Controls speed of rotation and zoom.

        self.curposindex = curposindex
       
       	#we call loadObjects which handles getting our objects in the world
	## TO DO::: Here: If the player is 'player1' self.loadObjects() but if it is 'player2' load .dat file with only the objects left by player1!!!!!

        #self.loadObjects()
        
        self.setupLighting()


	# Setup key controls
        # To Do: Implement zoom in & out + collision
	self.accept("escape", sys.exit) 
        self.accept("arrow_right", self.rotate,[1]) 
	self.accept("arrow_left", self.rotate,[-1])
        self.accept("o", self.cameraFocus,[-1])
        self.accept("l", self.cameraFocus,[1])
        self.accept("arrow_up", self.walk, [-1]) 
	self.accept("arrow_down", self.walk, [1])

        #set the camera position (x, y, z)
	base.camera.setPosHpr(Vec3(-60,-60, -3),Vec3(-30,-5,0))    #(Y,X,Z)manipulating 'z' you can go up/down, 'y' in and out of the pic, 'x' + goes left and '-' goes right & 'y' goes up and down
	#set the camera orientation (heading(yaw), pitch, roll) in degrees
 	
	#set Field of View to be wider as our room is quite reduced in size
	base.camLens.setFov(90)
	#base.camLens.setFar(100000) #this line of code doesn't seem to do anything
        ###new code to deal with server/client
#        self.blocksize = 16  #don't know if we'll need this
        self.playerlist = {}
        self.moverlist = set([])
        self.connected = False
        self.loggedIn = False
        self.sendPlayerPos = False
        self.wbUpdate = True

        print "before trying server connection"
        #Try connecting to server
        try:
            self.initNetwork()
            print "connection to server established"
        except:
            print "no server found"
            sys.exit()
        #end __init__


    #def self.loadGui(self):
    def loadGui(self):
        #load the GUI!
        pass
  
    def loginScreen(self):
        self.frame = DirectFrame(frameColor=(1,0,1,1), frameSize=(-1,1,0,1))
        self.unEntry = DirectEntry(initialText="Username",
                                   scale=0.08,
                                   text_scale=(1,1),
                                   pos=(-.7,0,.7))
        self.unEntry.reparentTo(self.frame)
         
        self.pwEntry = DirectEntry(initialText="Password",
                                   scale=0.08,text_scale=(1,1),
                                   pos=(-.7,0,.55),obscured=1)
        self.pwEntry.reparentTo(self.frame)
        
        self.loginbutton = DirectButton(text = "Login",
                                        pos=(0.26,0,.7),
                                        scale=0.08,
                                        command=self.login)
        self.loginbutton.reparentTo(self.frame)
        
        self.regbutton = DirectButton(text = "register",
                                      pos=(0.26,0,.57),
                                      scale=0.08,
                                      command=self.registeracc)
        
        self.regbutton.reparentTo(self.frame)

Hi,

Sorry, but your code is a mess. Nothing is correctly indented.

When I reformatted your code, it didn’t run. That is because you didn’t call run() at all. When I added it I saw nothing. Just a gray screen.
That was because you didn’t make an instance to your world class. When I did, all kinds of functions were missing.

Are you sure you posted the correct code?

Hi Pro-rsoft!

Sorry if the code was a mess. I used the wrong editor to copy and paste! I have tided it up a bit (see below) and it now does what I explained in the previous posting. When you run it you can see the frame but when you try to input text in the password or username fields nothing happens. There is no way to type anything into this fields.

The .get() function to grab the text from the field works fine though and it grabs the initial text displyed i.e. Username.

I am not including the totality of the code here, just an example illustrating the point I am explaining here.

Hope you can help. Thanks

from pandac.PandaModules import loadPrcFileData  #Modifies/adds the .prc (Panda3D's configuration file) 
#loadPrcFileData("", "client-sleep 0.03")
#loadPrcFileData("", "interpolate-frames 1")

#encoding: UTF-8

import direct.directbase.DirectStart  #starts the Game (opens an empty window)
from pandac.PandaModules import *     #Contains most of Panda's modules
from pandac.PandaModules import Material
from direct.gui.DirectGui  import *   #Imports Gui objects we use for putting text ont the screen
from direct.showbase.DirectObject import DirectObject  #to listen for events
from direct.showbase.ShowBaseGlobal import *
from direct.actor.Actor import Actor   #to use animated actors
from direct.interval.IntervalGlobal import *  #to use intervals
from direct.task import Task  #to use tasks
from direct.distributed.PyDatagram import PyDatagram  #to send data to server
from direct.distributed.PyDatagramIterator import PyDatagramIterator 
import math  #to use math (angles,degrees..etc)
import random
import re
import MySQLdb
import socket
from md5 import md5

#load first environment model
import sys, os

# Function to put instructions on the screen.
def addInstructions(pos, msg):
    return OnscreenText(text=msg, style=1, fg=(1,1,1,1),
			pos=(-1.3, pos), align=TextNode.ALeft, scale = .05)

# Function to put title on the screen.
def addTitle(text):
    return OnscreenText(text=text, style=1, fg=(1,1,1,1),
	                pos=(1.3,-0.95), align=TextNode.ARight, scale = .07)

#Find out what dir this program is in
AppPath = os.path.abspath(sys.path[0])
AppPath = Filename.fromOsSpecific(AppPath).getFullpath()
#print AppPath

curposindex =[]

class World(DirectObject):                          #our main class

    def __init__(self):               #iniialization method caused when a world object is created
    
	# Post instructions on screen
	self.title = addTitle("Psychology Dept. Glasgow")
	self.inst1 = addInstructions(0.95, "[ESC]: Quit")
	self.inst2 = addInstructions(0.90, "[Left Arrow]: Turn camera left")
       	self.inst3 = addInstructions(0.85, "[Right Arrow]: Turn camera right")
	self.inst4 = addInstructions(0.75, "[O]: Move camera forwards")
	self.inst5 = addInstructions(0.70, "[L]: Move camera backwards")
        #make background color black (R=0, B=0, G=0) intead of default grey
	base.setBackgroundColor(0, 0, 1)
	base.disableMouse()
	self.speed = .10 # Controls speed of rotation and zoom.

        self.curposindex = curposindex
       
        #call login-screen in readTask function
        taskMgr.add(self.readTask, "readTask", -39)

    #def self.loadGui(self):
    def loadGui(self):
        #load the GUI!
        pass
  
    def loginScreen(self):
        self.frame = DirectFrame(frameColor=(1,0,1,1), frameSize=(-1,1,0,1))
        self.unEntry = DirectEntry(initialText="Username",
                                   scale=0.08,
                                   text_scale=(1,1),
                                   pos=(-.7,0,.7))
        self.unEntry.reparentTo(self.frame)
         
        self.pwEntry = DirectEntry(initialText="Password",
                                   scale=0.08,text_scale=(1,1),
                                   pos=(-.7,0,.55),obscured=1)
        self.pwEntry.reparentTo(self.frame)
        
        self.loginbutton = DirectButton(text = "Login",
                                        pos=(0.26,0,.7),
                                        scale=0.08)
        self.loginbutton.reparentTo(self.frame)
        
        self.regbutton = DirectButton(text = "register",
                                      pos=(0.26,0,.57),
                                      scale=0.08)
        
        self.regbutton.reparentTo(self.frame)

    def readTask(self,task):
        ##test
        self.loginScreen()
        ###---
        self.loadGui()

   
w = World()
run()

It works fine for me. I can just click a textbox and enter text.
Must be a OSX specific problem.

Hi Pro-rsoft,

Thank you for trying it.
What I read from another person in the Forum is that entering text in DirectEntry works fine on Windows but there seems to be a problem on osx. I was wondering if anyone had found a way to fix it.

It works fine on Linux too.

A suggestion: use self.accept to get keypresses and enter the text into the box manually?

[size=84]By the way, your indents are still terribly messed-up.[/size]

DirectEntries work fine for me on OSX. I’m not aware of any OSX-related issues with DirectEntries.

Of course, this website is not yet officially providing an OSX build for Panda, so whatever you’re running on OSX, it must have been built unofficially. Kind of difficult for us to support that.

What forum thread are you referring to, and what build of Panda are you running?

David

Hi David. Thank you very much for your reply.

Have you tried the code I posted on your mac (see previous posts)? I would be interested to know if that works on your mac.
I am working on a Intel MacBook 10.4.8 and I haven’t been able to enter any text using DirectEntry.

I downloaded the Panda3D version I’m using is Panda3D-0.5-Intel from knuddl.net/moin.cgi/InstallPanda3d as it was the only Intel version available online. There must be some other people out there using this version.

I have used wxPython in the past so players could enter information before and after the game and that worked fine. However, for the new game we’re writing I wanted to try the Direct tools as everything is then displayed in one window.

Any ideas on how to fix this problem are welcome.

Thanks