Advertisement
Guest User

Untitled

a guest
Dec 31st, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 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')
  11. e_sad = widgets.button(form, text='Sad')
  12. e_angry = widgets.button(form, text='Angry')
  13. e_fearful = widgets.button(form, text='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. button_clicked = form._exec()
  29.  
  30. # Determine the starting time of the form item:
  31. starting_time = self.get(form)
  32.  
  33. # Determine the current time:
  34. current_time = self.time()
  35.  
  36. # The time it took to complete the form base is the
  37. # difference score between the two:
  38. sub_rt = current_time - starting_time
  39.  
  40. # Set the new variable for future use in the
  41. # GUI (notably, the logger item):
  42. exp.set("sub_rt", sub_rt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement