Changes
Jump to navigation
Jump to search
Line 411:
Line 411:
− Example using the buttonbox in Python: <nowiki>
+
+
+
− #import the rusocsci.buttonbox module
− +
− +
+
+
− +
+
− +
+
− Using the Buttonbox in PsychoPy: <nowiki>+
+
+
− #import psychopy and rusocsci
− from psychopy import core, visual from rusocsci import buttonbox
− +
− +
+
+
+
+
+
+
− +
− +
− +
− +
+
− +
− +
+
+
+
− +
no edit summary
== Buttonbox in Python and PsychoPy ==
== Buttonbox in Python and PsychoPy ==
Example using the buttonbox in Python:
<nowiki>
#!/usr/bin/env python
#!/usr/bin/env python
from rusocsci import buttonbox import logging, time
# import the rusocsci.buttonbox module
#make a buttonbox
from rusocsci import buttonbox
# make a buttonbox
bb = buttonbox.Buttonbox()
bb = buttonbox.Buttonbox()
#wait for a single button press
# wait for a single button press
b = bb.waitButtons()
b = bb.waitButtons()
#print the button pressed
# print the button pressed
print("b: {}".format(b)) </nowiki>
print("b: {}".format(b)) </nowiki>
Example using the Buttonbox in PsychoPy:
<nowiki>
#!/usr/bin/env python
#!/usr/bin/env python
##Setup Section
# import psychopy and rusocsci
win = visual.Window(monitor="testMonitor") bb = buttonbox.Buttonbox() text = visual.TextStim(win, "Press a button on the buttonbox")
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
## Experiment Section
#show text
# show text
text.draw() win.flip()
text.draw()
#wait for response
win.flip()
# wait for response
b = bb.waitButtons()
b = bb.waitButtons()
#show response
# show response
text.setText("you pressed: {}".format(b)) text.draw() win.flip() core.wait(5)
text.setText("you pressed: {}".format(b))
text.draw()
win.flip()
core.wait(5)
##Cleanup Section
## Cleanup Section
core.quit() </nowiki>
core.quit() </nowiki>