WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 09-28-2006, 11:04 AM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Ok, that worked, now the next step is for the program to recognize which button is pushed. Here is the code I have so far:
Code:
def mybutton(button,state):
 global SendText, infoindex, one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve
 letter = ''
 if button == send and button.get() == viz.DOWN:
  #Send the current text to the mailbox
  #Reset the text to nothing
  SendText = ''
  text.message(SendText)
  if infoindex <= 15:
   info.visible(1)
   infoindex = infoindex + 1
   one.remove(viz.BUTTON_LABEL)
   two.remove(viz.BUTTON_LABEL)
   three.remove(viz.BUTTON_LABEL)
   four.remove(viz.BUTTON_LABEL)
   five.remove(viz.BUTTON_LABEL)
   six.remove(viz.BUTTON_LABEL)
   seven.remove(viz.BUTTON_LABEL)
   eight.remove(viz.BUTTON_LABEL)
   nine.remove(viz.BUTTON_LABEL)
   ten.remove(viz.BUTTON_LABEL)
   eleven.remove(viz.BUTTON_LABEL)
   twelve.remove(viz.BUTTON_LABEL)
  elif infoindex > 15:
   text.visible(0)
   button.visible(0)
   HEAD_DEPTH = -12.5
   viz.translate(viz.HEAD_POS,0,0,HEAD_DEPTH )
   instructor1 = viz.add('male.cfg')
   instructor1.face('biohead_talk.vzf')
   instructor1.threatening = INSTRUCTOR
   instructor1.tag = 0
   instructor1.appearance = 0
   instructor1.facepic = 0 
   Instructions(instructor1)
   info.visible(0)
   #bulletinfo.visible(1)
 if viz.add(viz.BUTTON_LABEL,'a') and state == viz.DOWN:
  letter = 'a'
 elif viz.add(viz.BUTTON_LABEL,'b') and state == viz.DOWN:
  letter = 'b'
 elif viz.add(viz.BUTTON_LABEL,'c') and state == viz.DOWN:
  letter = 'c'
 elif viz.add(viz.BUTTON_LABEL,'d') and state == viz.DOWN:
  letter = 'd'
 elif viz.add(viz.BUTTON_LABEL,'e') and state == viz.DOWN:
  letter = 'e'
 elif viz.add(viz.BUTTON_LABEL,'f') and state == viz.DOWN:
  letter = 'f'
 elif viz.add(viz.BUTTON_LABEL,'g') and state == viz.DOWN:
  letter = 'g'
 elif viz.add(viz.BUTTON_LABEL,'h') and state == viz.DOWN:
  letter = 'h'
 elif viz.add(viz.BUTTON_LABEL,'i') and state == viz.DOWN:
  letter = 'i'
 elif viz.add(viz.BUTTON_LABEL,'l') and state == viz.DOWN:
  letter = 'l'
 elif viz.add(viz.BUTTON_LABEL,'m') and state == viz.DOWN:
  letter = 'm'
 elif viz.add(viz.BUTTON_LABEL,'n') and state == viz.DOWN:
  letter = 'n'
 elif viz.add(viz.BUTTON_LABEL,'o') and state == viz.DOWN:
  letter = 'o'
 elif viz.add(viz.BUTTON_LABEL,'p') and state == viz.DOWN:
  letter = 'p'
 elif viz.add(viz.BUTTON_LABEL,'r') and state == viz.DOWN:
  letter = 'r'
 elif viz.add(viz.BUTTON_LABEL,'s') and state == viz.DOWN:
  letter = 's'
 elif viz.add(viz.BUTTON_LABEL,'t') and state == viz.DOWN:
  letter = 't'
 elif viz.add(viz.BUTTON_LABEL,'u') and state == viz.DOWN:
  letter = 'u'
 elif viz.add(viz.BUTTON_LABEL,'v') and state == viz.DOWN:
  letter = 'v'
 elif viz.add(viz.BUTTON_LABEL,'x') and state == viz.DOWN:
  letter = 'x'
 elif viz.add(viz.BUTTON_LABEL,'y') and state == viz.DOWN:
  letter = 'y'
 elif viz.add(viz.BUTTON_LABEL,'z') and state == viz.DOWN:
  letter = 'z'
 SendText += letter
 text.message(SendText)
The problem I'm having is that no matter what button I push, an "a" is printed in text. Am I doing something wrong? Is it ok to use the if viz.add() to implement this? The way I see this code is that whatever button (letter) I press, that letter should be the next one to pop up. In other words, how can I access the BUTTON_LABEL attribute to use it in my if logic.

Last edited by betancourtb82; 09-28-2006 at 11:56 AM.
Reply With Quote
  #2  
Old 09-28-2006, 04:24 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
You can save the label somewhere when you assgin it.
Code:
buttonLabel = 'mylabel'
button = viz.add( viz.BUTTON, buttonLabel   )
button.label = buttonLabel

...

print button.label
I suggested something similar when you are attaching weapons to avatars.
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #3  
Old 10-03-2006, 12:05 PM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
I tried this but it gave me an error:
Code:
Traceback (most recent call last):
  File "<string>", line 12, in ?
  File "buttonsTest2.py", line 96, in ?
    button = viz.add(viz.BUTTON,buttonLabel)
  File "C:\Program Files\Vizard25\viz.py", line 4881, in add
    return addbutton(*args)
  File "C:\Program Files\Vizard25\viz.py", line 4102, in addbutton
    return VizCheckBox(_ipcSendHold(_VIZ_ADDCHECKBOX,scene-1,1,'',int(parent),0,0,0))
TypeError: unsupported operand type(s) for -: 'str' and 'int'
Reply With Quote
  #4  
Old 10-03-2006, 12:29 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The code should be:
Code:
button = viz.add(viz.BUTTON_LABEL,buttonLabel)
Reply With Quote
  #5  
Old 10-03-2006, 12:38 PM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Ok, thank you. I think i found a new approach. What I did is create a button in GUI field in vizard and if I click on the button, it displays the letter I want. The question I have now is how can I put a label on the button that I created in the GUI field. Is it the same as creating a label for a button that I made using coding?
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:47 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC