Changes

Jump to navigation Jump to search
20 bytes removed ,  10:11, 30 April 2014
no edit summary
Line 411: Line 411:     
== Buttonbox in Python and PsychoPy ==
 
== Buttonbox in Python and PsychoPy ==
 +
Example using the buttonbox in Python: <nowiki>
   −
Example using the buttonbox in Python:
+
#!/usr/bin/env python
<source lang="python>
+
#import the rusocsci.buttonbox module
#!/usr/bin/env python
     −
# import the rusocsci.buttonbox module
+
from rusocsci import buttonbox import logging, time
from rusocsci import buttonbox import logging, time
+
#make a buttonbox
 +
bb = buttonbox.Buttonbox()
 +
#wait for a single button press
 +
b = bb.waitButtons()
 +
#print the button pressed
 +
print("b: {}".format(b)) </nowiki>
   −
# make a buttonbox
+
Using the Buttonbox in PsychoPy: <nowiki>
bb = buttonbox.Buttonbox()
+
#!/usr/bin/env python
 +
#import psychopy and rusocsci
 +
from psychopy import core, visual from rusocsci import buttonbox
   −
# wait for a single button press
+
##Setup Section
b = bb.waitButtons()  
+
win = visual.Window(monitor="testMonitor") bb = buttonbox.Buttonbox() text = visual.TextStim(win, "Press a button on the buttonbox")
   −
# print the button pressed
+
##Experiment Section
print("b: {}".format(b))
+
#show text
</source>
+
text.draw() win.flip()
 +
#wait for response
 +
b = bb.waitButtons()
 +
#show response
 +
text.setText("you pressed: {}".format(b)) text.draw() win.flip() core.wait(5)
   −
Using the Buttonbox in PsychoPy:
+
##Cleanup Section
<source lang="python>
+
core.quit() </nowiki>
#!/usr/bin/env python
     −
# import psychopy and rusocsci
  −
from psychopy import core, visual
  −
from rusocsci import buttonbox
  −
  −
## Setup Section
  −
win = visual.Window(monitor="testMonitor")
  −
bb = buttonbox.Buttonbox()
  −
text = visual.TextStim(win, "Press a button on the buttonbox")
  −
  −
## Experiment Section
  −
# show text
  −
text.draw()
  −
win.flip()
  −
# wait for response
  −
b = bb.waitButtons()
  −
# show response
  −
text.setText("you pressed: {}".format(b))
  −
text.draw()
  −
win.flip()
  −
core.wait(5)
  −
  −
##Cleanup Section
  −
core.quit()
  −
</source>
   
== Matlab Settings ==
 
== Matlab Settings ==
  
Anonymous user

Navigation menu