Advertisement
Guest User

Untitled

a guest
Dec 31st, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement