DirectEntry-get the string without command?

how to get the current input of an directEntry without pressing enter?
i wanted to use it as input fileds for a username and passwort entry and provide 2 buttons (one for login and one for registrating the name+password).
my current workaround is chain of functinos called after another but thats pretty bad and i cant get the behaviour i want.
any ideas?

greetings
thomasegi

You can use entry.get() to return the current user text.

David

i tried the get() method but it only returns the initial string. or nothing if you dont enter an inital string
well maybe i did something wrong.
maybe you know what’s wrong with this:

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.gui.DirectGui import *

class world(DirectObject):
  def __init__(self):
    self.frame = DirectFrame(frameColor=(1,0,1,1), frameSize=(-1,1,0,1))
    
    self.entry = DirectEntry(initialText="Username",scale=0.05,text_scale=(1,1),pos=(-.7,0,.7))
    self.entry.reparentTo(self.frame)
    
    self.entry2 = DirectEntry(initialText="Password",scale=0.05,text_scale=(1,1),pos=(-.7,0,.6),obscured=1)
    self.entry2.reparentTo(self.frame)
    
    self.loginbutton = DirectButton(
    text = "Login",
    pos=(-.0,0,.7),
    scale=0.05,
    command=self.login,
    extraArgs = [
    self.entry.get(),
    self.entry2.get()
    ])
    
    self.loginbutton.reparentTo(self.frame)
    
  def login(self,input1,input2):
    print input1
    print input2
w = world()
run()

When you create self.loginbutton, the parameters to its constructor are evaluated at that time–so the extraArgs to the self.login() call are always going to be the initial values of self.extra and self.extra2, which is the value of get() at the time of the DirectButton constructor.

Instead of doing it this way, try passing self.extra and self.extra2 within the extraArgs, and call get() within the login() method.

David

and another big thx to you =) saved my weekend again^^.
works like a charm!

… guess you could make a living of it if everyone would spend a buck for a answer of yours :laughing: