WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-17-2007, 10:31 AM
Karla Karla is offline
Member
 
Join Date: May 2007
Posts: 12
Turning info boxes on and off

Below is the code from my .py file.

I would like to program info boxes to appear and disappear based on user input or a timer, not from clicking on the logo to shrink the box. For example, a box with 3 choices appears to collect the user's choice of phrase. It disappears after the user clicks OK. Then an info box appears to tell the user the avatar's reply. After 2 seconds (enough time to read the reply), that info box disappears. Then another box with 3 choices appears to collect the user's next choice of phrase, and so on. I'm having a problem with the timing.

After running the file, if you press '5' an info box will appear. Once you click the OK button, the first info box will disappear, but a second info box does not appear as it should. Line 74 should make this box appear; line 77 should wait 2 seconds; and line 78 should make this box disappear.

Any advice is greatly appreciated!

Thanks,
Karla


Code:
import viz

import vizinfo	#For message box
import viztask 	#For wait time

viz.go()

male = viz.add('male.cfg')	#Add an avatar
male.translate(0,0,1)
male.rotate(0,1,0,180)
male.state(1)				#Start in neutral state animation

face2 = male.face('biohead_talk.vzf')	#add a face to the avatar

smile = vizact.morph(0,2,0.5)		#Smiling face of male avatar
open = vizact.morph(5,0.5,0.5)	#mouth open morph of male avatar
				
# Make an action when a key is pressed.
def mykey(key):
	global subTalk, OKbutton, aRadio, bRadio, cRadio, charTalk
		
	if key == ' ':    			#if the pressed key is space bar
		face2.add(smile) 		#Smiling face of male avatar
		face2.add(open) 		#Open mouth face of male avatar
		male.state(5)   		#Wave animation of male avatar
	
	#Show a Transparent Message Box 
	if key == '5': #if the pressed key is '5'
		subTalk = vizinfo.add("")		#Add the vizinfo object
		subTalk.translate(1.0,.95) 		#Set position on screen
		subTalk.title("Chat Box") 		#Give it a title.
		subTalk.visible(viz.ON)  		#Display the Message Box
		aRadio = subTalk.add(viz.RADIO, 0, "Hello.")	#Create a Radio button
		bRadio = subTalk.add(viz.RADIO, 0, "What is your street address?")
		cRadio = subTalk.add(viz.RADIO, 0, "What is your pet's name?")
		astext = "Hello."
		bstext = "What is your street address?"
		cstext = "What is your pet's name?"
		OKbutton = subTalk.add(viz.BUTTON, "OK")		#Create a button
		print aRadio.get()
		
viz.callback(viz.KEYBOARD_EVENT,mykey)

# Make an action when a BUTTON is pressed.
def onButton (button,state):
	global subtalk, OKbutton, aRadio, bRadio, cRadio, charTalk
	if button == OKbutton and state == viz.DOWN:
		aans = aRadio.get()
		bans = bRadio.get()
		cans = cRadio.get()		
		viztask.waitTime(1) 		#Wait 1 second
		subTalk.visible(viz.OFF)  #Remove the Message Box
		if aans == 1: 
			charTalk = vizinfo.add("It's nice to meet you.")
			print "A."
		elif bans == 1: 
			charTalk = vizinfo.add("Uh, that's personal. I'm Alex. Who are you?")
			print "B."
		elif cans == 1: 
			charTalk = vizinfo.add("Uh, that's personal. I'm Alex. Who are you?")
			print "C."   
		else:
			print "none"
		charTalk.translate(1.0,.95) 	#Set position on screen
		charTalk.title("Chat Box") 		#Give it a title.
		charTalk.visible(viz.ON)  		#Display the Message Box
		print aans
		
		viztask.waitTime(2) 			#Wait 2 seconds to read avatar's response
		charTalk.visible(viz.OFF)  		#Remove the Message Box
		print bans
	else:
		print "place holder"
viz.callback(viz.BUTTON_EVENT, onButton)

def mytimer(num):
	
	viz.callback(viz.TIMER_EVENT,mytimer)
	viz.starttimer(0,0.01,viz.FOREVER)


#***********************************************************
#Adding a world
#***********************************************************
room = viz.add('panorama.ive')
room.scale(1,1,1)  		# scale actual
room.translate(0,0,0) 	# position in the world
Reply With Quote
 


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:25 PM.


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