Ejemplo n.º 1
0
def present_trial(imagepath):
	"""
	This is the main function used to run this demo. It is fed an imagepath and uses this to create a CommandableImageSprite offscreen. This Sprite is later moved onto the screen, where it hangs out until it is clicked.

	"""
	## Images here are commandable sprites, so we can tell them what to do using Q below
	img = TobiiSprite( screen, spot.center, imagepath, tobii_controller, scale=IMAGE_SCALE)
	img.enable_follow()

	drum = DropSprite(screen, (609,407), kstimulus("common_objects/drum.png"), scale=IMAGE_SCALE)

	img.register_drag_zone(drum)

	images = [drum, img]

	# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
	# Set up the updates, etc. 
	
	# A queue of animation operations
	Q = DisplayQueue()
	
	# What order do we draw sprites and things in?
	dos = OrderedUpdates(images) # Draw and update in this order
	
	start_time = time()

	#start tracking
	tobii_controller.start_tracking()	
	
	## The standard event loop in kelpy -- this loops infinitely to process interactions
	## and throws events depending on what the user does
	for event in kelpy_standard_event_loop(screen, Q, dos, throw_null_events=True):

	# This also turns it off when the sprite it not looked at any longer.
		img.process_follow(event)   ## simple, right?

		if was_dragged_into_zone(event):  ## This is a function located in the EventHandler that watches for drag zone events.
			print "Nice Drumming!"
			play_sound(kstimulus("sounds/Button-Reverb.wav"))

		if event.type == QUIT:
			tobii_controller.close_data_file()
			tobii_controller.destroy()
				
		
	tobii_controller.stop_tracking()