Advertisement
Guest User

confirm_abort_experiment

a guest
Feb 5th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1.     def confirm_abort_experiment(self):
  2.         """
  3.         Asks for confirmation before aborting the experiment.
  4.         Displays a confirmation screen, collects the response, and acts accordingly
  5.  
  6.         Raises a response_error upon confirmation
  7.  
  8.         """
  9.         # Display the confirmation screen
  10.         yc = self.my_canvas.ycenter()
  11.         ld = 40
  12.         self.my_canvas.clear()
  13.         self.my_canvas.text("Really Abort experiment?", y = yc - 3 * ld)
  14.         self.my_canvas.text("Hit 'Y' to abort, ", y = yc - 0.5 * ld)
  15.         self.my_canvas.text("Hit any other key or wait 5s to go to setup, ", y = yc + 0.5 * ld)
  16.         self.my_canvas.show()
  17.  
  18.         # process the response:
  19.         try:
  20.             key, time = self.my_keyboard.get_key(timeout = 5000)
  21.         except:
  22.             self.setup_cal_display()
  23.             return
  24.        
  25.         # if confirmation, close experiment
  26.         if key == 'y':
  27.             raise openexp.exceptions.response_error( \
  28.                             "The experiment was aborted")
  29.         else:
  30.             self.setup_cal_display()
  31.             return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement