Password Field in DirectEntry

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.

Some how I missed the reference to obscured as a DirectEntry arg.

obscured True to hide passwords, etc. 0 or 1

loquack. Something must be wrong here. I copied and pasted your coded just to see how a directgui program should work. When I ran it here is what I got.

---------- Capture Output ----------

“C:\Panda3D-1.3.1\python\ppython.exe” PasswordEntry.py
Warning: DirectNotify: category ‘Interval’ already exists
Terminated with exit code 0.

Do you have any idea what is wrong?

Ok loquack: After reading your second post. I renamed the original script in your first post to conn.py. I then copied and pasted the second script and saved it with then name. InputBoxExample.py. I then ran ppyton and here is the output I got

---------- Capture Output ----------

“C:\Panda3D-1.3.1\python\ppython.exe” InputBoxExample.py
DirectStart: Starting the game.
Warning: DirectNotify: category ‘Interval’ already exists
Known pipe types:
wdxGraphicsPipe8
(3 aux display modules not yet loaded.)
:util(warning): Adjusting global clock’s real time by 8.88371 seconds.
:gobj(error): Texture::read() - couldn’t read: /c/Documents and Settings/Dennis DeBerry/Desktop/MyProjects/Panda3d/escape1.png
:gobj(error): Texture “/c/Documents and Settings/Dennis DeBerry/Desktop/MyProjects/Panda3d/escape1.png” does not exist.
Traceback (most recent call last):
File “InputBoxExample.py”, line 4, in ?
h = conn.conWin()
File “C:\Documents and Settings\Desktop\MyProjects\Panda3d\conn.py”, line 32, in init
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)
File “C:\Panda3D-1.2.3\direct\src\gui\DirectFrame.py”, line 47, in init
File “C:\Panda3D-1.2.3\direct\src\gui\DirectGuiBase.py”, line 237, in initialiseoptions
File “C:\Panda3D-1.2.3\direct\src\gui\DirectFrame.py”, line 179, in setImage
File “C:\Panda3D-1.2.3\direct\src\gui\DirectGuiBase.py”, line 557, in createcomponent
File “C:\Panda3D-1.2.3\direct\src\gui\OnscreenImage.py”, line 49, in init
File “C:\Panda3D-1.2.3\direct\src\gui\OnscreenImage.py”, line 110, in setImage
TypeError: NodePath::set_texture() argument 1 must be Texture, not NoneType
Terminated with exit code 1.

Now this is REALLY strange since I do not have a C:\Panda3d-1.2.3\ directory on my hard drive. Panda is installed in C:\Panda3d-1.3.1 as I have upgraded in the last few months. So I am nor REALLY confused about what is going on.

Shaba,

If you previously had Panda3D 1.2.3 installed, you may need to check your system paths to make sure that it is no longer on the searchpath. Right-click on “My Computer,” select “Properties,” go to the “Advanced” tab, and click “Environment Variables.” Then look at the PATH variable and check for instances of 1.2.3.

Ok I checked my path statment. Nope It points to C:\Panda3d-1.3.1;C:\Panda3d-1.3.1\python;C:\Panda3d-1.3.1\bin. I did have 1.2 on this machine but uninstalled it and did a totally new install of 1.3.1 then when 1.3.2 came out did and new install of that OVER 1.3.1. I jsut have not changed the folder name or the path statment since all the files are in the same directory. The only thing I can think of is if maybe a panda install adds something to the Windows registry but I have never heard of that.

Any ideas?

Check out your panda.pth file in the python directory. If python starts looking for the 1.2.x folder and can’t find it, it will burp.