View Single Post
  #5  
Old 12-04-2008, 01:20 PM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
The tutorial mentioned above uses the same code and it works, though...

Code:
import viz

import time

viz.go()

subject = viz.input('What is the participant number?')
viz.add('duck.cfg').translate(0,0,4)
critical_question = viz.add(viz.TEXT3D,'Do you see a duck?',viz.SCREEN)

yes = viz.add(viz.TEXT3D, 'Yes!',viz.SCREEN)
no = viz.add(viz.TEXT3D, 'No!',viz.SCREEN)

critical_question.alignment(viz.TEXT_CENTER_TOP)
critical_question.translate(.5,.9)

yes.alignment(viz.TEXT_LEFT_TOP)
yes.translate(.25,.75)

no.alignment(viz.TEXT_LEFT_TOP)
no.translate(.75,.75)

yes_button = viz.add(viz.BUTTON)
yes_button.translate(.22,.71)

no_button = viz.add(viz.BUTTON)
no_button.translate(.72,.71) 

start_time = time.time()
question_data = open('duck_data','a')
def onbutton(obj,state):
    #Use our starting time variable to find out how much
    #time has elapsed.
    elapsed_time = time.time() - start_time
    #Create string lines to put in the data file, depending on which
    #button was pushed.
    if obj == yes_button:
        data = 'Subject ' + str(subject) + ' saw a duck.'
    if obj == no_button:
        data = 'Subject ' + str(subject) + ' did not see a duck.'
    #Write the data to our file.
    question_data.write(data)
    #Flush the internal buffer.
    question_data.flush()
    #Close the world.
    viz.quit()

viz.callback(viz.BUTTON_EVENT,onbutton)
In this, the file they're trying to open is duck_data; my file is called score_data, is that too generic?
Reply With Quote