Is there a option for DirectEntry to obscure the text entered with a mask like ****. I’m trying to create a login screen with obfuscated password field.
Here is my code so far (my first panda attempt).
from direct.gui.OnscreenText import OnscreenText, TextNode, Vec3
from direct.gui.DirectGui import DirectFrame, DirectButton, DirectEntry, DirectLabel, DGG
from direct.showbase.DirectObject import *
import sys,os
from pandac.PandaModules import Filename
class conWin:
def __init__(self):
mydir = os.path.abspath(sys.path[0])
mydir = Filename.fromOsSpecific(mydir).getFullpath()
#image file
img = mydir + "/escape1.png"
# vertical space from top
V_SPACE = 0.0
# vertical size of console
V_SIZE = 1.5
# size of the text
MSCALE = 0.05
# when changing scale change this as well
LINELENGTH = 80
top = 1/MSCALE - (V_SPACE/MSCALE)
bottom = 1/MSCALE - (V_SPACE/MSCALE) - (V_SIZE/MSCALE)
#add some text
bk_text = "Welcome to Planescape"
textObject = OnscreenText(text = bk_text, pos = (0.95,-0.95),
scale = 0.07, fg = (1,0.5,0.5,1), align = TextNode.ACenter, mayChange = 1)
a = DirectFrame( relief = DGG.GROOVE, frameSize = (-1/MSCALE, 1/MSCALE, top, bottom), image = img, image_scale = (20.0, 0.0, 15.0), image_pos = (0.0, 0.0, 5.0), scale = MSCALE)
l1 = DirectLabel(parent = a, text = "Username", text_fg = (255, 255, 35, 15), text_bg = (24,0,0,0), pos = Vec3( 2.5, 0.0, 1.25 ))
b = DirectEntry(parent = a, text = "" , scale=0.5, pos = Vec3( 0.0, 0.0, 0.0 ), command = self.setText,
initialText="", numLines = 1)
l2 = DirectLabel(parent = a, text = "Password", pos = Vec3( 2.5, 0.0, -1.25 ))
b2 = DirectEntry(parent = a, text = "", scale = 0.5, pos = Vec3( 0.0, 0.0, -2.5 ), command = self.setText,
initialText="", numLines = 1)
c = DirectButton(parent = a, text = ("Connect", "Going", "GO!", "disabled"), scale = 1.0, pos = Vec3( 2.5, 0.0, -4.0 ))
#callback function to set text
def setText(textEntered):
textObject.setText(textEntered)
The above script is called by
import direct.directbase.DirectStart
import conn
h = conn.conWin()
run()
Also good to note I am knowlegable in PHP, C, C++, Fortran, Java but I’m a python noob.