Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 26a27
- > import openexp.exceptions
- 76c77
- <
- ---
- > experiment.eyelink_esc_pressed = False
- 311a313
- > self.experiment.eyelink_esc_pressed = False
- 321c323,324
- < while True:
- ---
- > # 'silly loop, it should be left out:'
- > # while True:
- 326c329,330
- < error = pylink.getEYELINK().doDriftCorrect(pos[0], pos[1], 0, 1)
- ---
- > print 'attempting drift correct...'
- > error = pylink.getEYELINK().doDriftCorrect(pos[0], pos[1], 0, 0)
- 330a335
- > # TODO "...escape or q pressed" ?
- 333c338
- < except:
- ---
- > except Exception, e:
- 399c404,412
- < if my_keyboard.get_key()[0] != None:
- ---
- > try:
- > key,time = my_keyboard.get_key()
- > except:
- > # if escape key pressed:
- > self.experiment.eyelink_esc_pressed = True
- > self.recording = False
- > return False
- > else:
- > if key != None: # i.e. 'q' was pressed
- 403a417
- >
- 486d499
- <
- 661d673
- <
- 692d703
- <
- 737a749,780
- > def confirm_abort_experiment(self):
- > """
- > Asks for confirmation before aborting the experiment.
- > Displays a confirmation screen, collects the response, and acts accordingly
- >
- > Raises a response_error upon confirmation
- >
- > """
- > # Display the confirmation screen
- > conf_canvas = canvas(self.experiment)
- > conf_kb = keyboard(self.experiment, timeout = None)
- > yc = conf_canvas.ycenter()
- > ld = 40
- > conf_canvas.clear()
- > conf_canvas.text("Really abort experiment?", y = yc - 3 * ld)
- > conf_canvas.text("Hit 'Y' to abort, ", y = yc - 0.5 * ld)
- > conf_canvas.text("Hit any other key or wait 5s to go to setup, ", y = yc + 0.5 * ld)
- > conf_canvas.show()
- >
- > # process the response:
- > try:
- > key, time = conf_kb.get_key(timeout = 5000)
- > except:
- > return False
- >
- > # if confirmation, close experiment
- > if key == 'y':
- > raise openexp.exceptions.response_error( \
- > "The experiment was aborted")
- > else:
- > return False
- >
- 758d800
- <
- 957a1000
- > self.experiment.eyelink_esc_pressed = False
- 1105c1148,1150
- < _key, time = self.my_keyboard.get_key()
- ---
- > key, time = self.my_keyboard.get_key()
- > except openexp.exceptions.response_error:
- > key = 'escape'
- 1109,1114d1153
- < if _key == None:
- < return None
- <
- < ky = []
- < key = self.my_keyboard.to_chr(_key)
- <
- 1138a1178,1181
- > elif key == "escape": # escape does the same as 'q', but also marks esc_pressed
- > self.experiment.eyelink_esc_pressed = True
- > keycode = pylink.ESC_KEY
- > self.state = None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement