![]() |
|
|
|
#1
|
|||
|
|||
|
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)
Last edited by betancourtb82; 09-28-2006 at 11:56 AM. |
|
#2
|
|||
|
|||
|
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
__________________
Paul Elliott WorldViz LLC |
|
#3
|
|||
|
|||
|
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'
|
|
#4
|
|||
|
|||
|
The code should be:
Code:
button = viz.add(viz.BUTTON_LABEL,buttonLabel) |
|
#5
|
|||
|
|||
|
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?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|