Hi,
I am not sure if this is the right place to post this problem but I thought I might get more help in this topic as it is osx specific.
I am trying to use DirectEntry to save the username and password of my players. However, on the mac there seems to be a problem and I am not able to enter any text in the username and password fields.
Anyone can help with this. I am attaching an example code of what I am using.
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()