GUI menu

Hi everyone. I’m trying to make menu for my game. However when I try to use the DirectButton I seem to fail lol. I know that DirectButton uses “commands=” to send you to someplace to do a order. I can do that, but after a few orders I have to start using the self. bla bla bla inorder for the program to tell what I am telling it to do (I change the window size and delete things over and over again alot). So I tried using a more linar apporch to it using Ifs witch doesnt seem to work either. It seems that after setting up the screen with everything I need on there, thats the end and the code wont go on to the nexts line. So I was wounding how would you go about setting it up better or maybe changing the code to work lol?
Heres a sample:

Name = DirectEntry(pos=(-.6,0,-.6),scale=.08,width=10,text_scale=(1.5,1.5),rolloverSound=0,clickSound=0,cursorKeys=1)
Name.reparentTo(frame) 
Password = DirectEntry(pos=(-.6,0,-.9),scale=.08,width=10,text_scale=(1.5,1.5),obscured=1,rolloverSound=0,clickSound=0,cursorKeys=1)
Password.reparentTo(frame)
Logo = OnscreenImage(image = 'death.jpg',pos = (0,0,.35),parent=render2d,scale = (.5,.5,.5))
Logon = DirectButton(text = ("Logon"),rolloverSound=0,clickSound=0,pos=(0,0,-.35),scale=.08,extraArgs=[goto="1"],text_scale=(1.5,1.5))
Logon.reparentTo(frame)
if goto == "1":
  goto="0"
  data="namepass"+" "+Name.get()+" "+Password.get()
  client.send(data)
  data = client.recv(1024)
  if data == "1":
    Name.removeNode()
    Password.removeNode()
    Logo.removeNode()
    Logon.removeNode()
    data = ""

I’m actually developing an alternative interface to basic widgets that make use of html coupled with css.
It is in prealpha stage but you can actually render nice and pretty complex text formatting and basic forms.
As an example, the following code, coupled with a little html, prompt a input box with a submit button, capable to load a different html page pressing the submit button:

if __name__ == '__main__':
  #=======================================
  def formaction(action, inputs):
    global ht
    if action == "to_form_a":
      toformA()
    elif action == "to_form_b":
      toformB()
  #=======================================
  def toformA():
    global ht
    htmlfile='htest_formA.html'
    html=open(htmlfile,'r').read()
    ht.onParse(html)
  #=======================================
  def toformB():
    global ht
    htmlfile='htest_formB.html'
    html=open(htmlfile,'r').read()
    ht.onParse(html)
  #=======================================
  ht=htmltext(parent=base.a2dTopLeft, wrap=1.)
  ht.form_action=formaction
  ht.setPos(0,0,0)
  toformA()
  run()

If you’re interested I’ll be happy to share my scripts to you (and other brave people as well of course) but keep in mind that they relies on the ‘cutting edge’ panda3D version on CVS so you got to be able to download and build the latest panda3d code.

what I did was have each button linked to a global function handler. For instance if it was a button that would change the page it would be sent to a function where every pages init and destroy functions where nested in 2 switch blocks. It starts to get really messy with large or complex menus, but it runs rather smoothly and is pretty easy to understand (and its really easy to find and edit a page setup). Here’s a quick code sample for what I mean:

#sample button
b = DirectButton(text = "Return to Options", ... , command= gotoPage, extraArgs= ["Difficulty", "Options"])

#global function handler- goto page function
def gotoPage(currentPage, toPage):
     #clean old page
     switch(currentPage):
     case "Difficulty":
          cleanDifficulty()
     ...
     ...

     #make new page
     switch(toPage):
     case "Options":
          initOptions()
     ...
     ...

where cleanDifficulty() is the function that deletes all GUI objects on that page and initOptions() is the function that creates all GUI objects for that page. Note* each page will have 2 functions of varying sizes (large/complex menus = ALOT of functions using this method)