Created
January 15, 2015 14:31
-
-
Save lindemann09/526e5285d2c55c11529a to your computer and use it in GitHub Desktop.
wait callback functions in Expyriment (0.7)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Demonstration of wait callback functions in Expyriment | |
""" | |
from expyriment import control, design, misc, io, stimuli | |
control.defaults.quit_key = None # switch off quitting key | |
# my wait callback function | |
def check_keyboard(): | |
global feedback_value | |
key = io.Keyboard().check() | |
if key == misc.constants.K_ESCAPE: | |
stimuli.TextScreen("Feedback {0}".format(feedback_value), | |
"Quitting Experiment? (y/n)").present() | |
key, rt = io.Keyboard().wait_char(["y", "n"], check_for_control_keys=False) | |
print key | |
if key == "y": | |
control.end() | |
exit() | |
exp = control.initialize() | |
control.start(exp) | |
feedback_value = 0 | |
while True: # wait forever | |
feedback_value += 1 | |
stimuli.TextScreen("Demo quit wait", "press ESC to quit").present() | |
exp.clock.wait(10000, function=check_keyboard) | |
control.end() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment