Advertisement
Guest User

Untitled

a guest
Dec 31st, 2013
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. # Import the widgets library
  2. from libopensesame import widgets
  3. from random import shuffle
  4. # Create a form
  5. form = widgets.form(self.experiment, cols=[1,1,1,1], rows=[4,1,1],
  6. margins=(50,100,50,100), spacing=10)
  7.  
  8. # Create five widgets
  9. image = widgets.image(form, path=self.experiment.get_file(self.get('facestims')))
  10. e_happy = widgets.button(form, text='Happy', var = 'e_happy')
  11. e_sad = widgets.button(form, text='Sad', var = 'e_sad')
  12. e_angry = widgets.button(form, text='Angry', var = 'e_angry')
  13. e_fearful = widgets.button(form, text='Fearful', var = 'e_fearful')
  14. # Creat a list with 4 random numbers from 0:3
  15. #Add the widgets to the form. The position in the form is indicated as a
  16. # (column, row) tuple.
  17.  
  18. i=range(4)
  19. shuffle(i)
  20. form.set_widget(image, (0,0),colspan=4, rowspan=2)
  21. form.set_widget(e_happy, (i.pop(),2))
  22. form.set_widget(e_sad, (i.pop(),2))
  23. form.set_widget(e_angry, (i.pop(),2))
  24. form.set_widget(e_fearful, (i.pop(),2))
  25. # Execute the form! In this case, the form will return the text of the button that
  26. # was clicked. This is one way to get a return value out of the form. Another way
  27. # is to use the 'var' keyword, supported some of the widgets.
  28. starting_time = self.time()
  29.  
  30. button_clicked = form._exec()
  31.  
  32. # Determine the current time:
  33. current_time = self.time()
  34.  
  35. # The time it took to complete the form base is the
  36. # difference score between the two:
  37. sub_rt = current_time - starting_time
  38.  
  39. # Set the new variable for future use in the
  40. # GUI (notably, the logger item):
  41. exp.set("sub_rt", sub_rt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement