Ejemplo n.º 1
0
 def setup_class(self):
     self.questions = []
     self.win = Window(units='height', allowStencil=True, autoLog=False)
     # create some questions
     self.genderItem = {
         "questionText": "What is your gender?",
         "questionWidth": 0.7,
         "type": "radio",
         "responseWidth": 0.3,
         "options": "Male, Female, Other",
         "layout": 'vert',
         "index": 0
     }
     self.questions.append(self.genderItem)
     # then a set of ratings
     items = ["running", "cake", "programming"]
     for idx, item in enumerate(items):
         entry = {
             "questionText": "How much you like {}".format(item),
             "questionWidth": 0.7,
             "type": "rating",
             "responseWidth": 0.3,
             "options": "Lots, some, Not a lot, Longest Option",
             "layout": 'horiz',
             "index": idx + 1
         }
         self.questions.append(entry)
     self.survey = Form(self.win,
                        items=self.questions,
                        size=(1.0, 0.3),
                        pos=(0.0, 0.0),
                        autoLog=False)
Ejemplo n.º 2
0
    def setup_class(self):
        # Create temp files for storing items
        self.temp_dir = mkdtemp()
        self.fileName_xlsx = os.path.join(self.temp_dir, 'items.xlsx')
        self.fileName_csv = os.path.join(self.temp_dir, 'items.csv')

        # create some questions
        self.questions = []
        self.genderItem = {
            "questionText": "What is your gender?",
            "questionWidth": 0.7,
            "type": "radio",
            "responseWidth": 0.3,
            "options": "Male, Female, Other",
            "layout": 'vert',
            "index": 0,
            "questionColor": "white",
            "responseColor": "white"
        }
        self.questions.append(self.genderItem)
        # then a set of ratings
        items = ["running", "cake", "programming"]
        for idx, item in enumerate(items):
            entry = {
                "questionText": "How much you like {}".format(item),
                "questionWidth": 0.7,
                "type": "rating",
                "responseWidth": 0.3,
                "options": "Lots, some, Not a lot, Longest Option",
                "layout": 'horiz',
                "index": idx + 1,
                "questionColor": "white",
                "responseColor": "white"
            }
            self.questions.append(entry)

        self.win = Window(units='height', allowStencil=True, autoLog=False)
        self.survey = Form(self.win,
                           items=self.questions,
                           size=(1.0, 0.3),
                           pos=(0.0, 0.0),
                           autoLog=False)

        # Create datafiles
        df = DataFrame(self.questions)
        df.to_excel(self.fileName_xlsx, index=False)
        df.to_csv(self.fileName_csv, index=False)
Ejemplo n.º 3
0
    def setup_class(self):
        self.win = Window([128, 128],
                          pos=[50, 50],
                          allowGUI=False,
                          autoLog=False)
        self.obj = Slider(self.win,
                          units="height",
                          size=(1, 0.1),
                          pos=(0, 0.5),
                          style='radio')
        self.obj.markerPos = 1

        # Pixel which is the border color
        self.borderPoint = (0, 127)
        self.borderUsed = True
        # Pixel which is the fill color
        self.fillPoint = (0, 0)
        self.fillUsed = True
        # Pixel which is the fore color
        self.forePoint = (0, 0)
        self.foreUsed = False
Ejemplo n.º 4
0
 def setup_class(self):
     self.questions = []
     self.win = Window(units='height', allowStencil=True)
     # create some questions
     self.genderItem = {"qText": "What is your gender?",
                   "qWidth": 0.7,
                   "aType": "choice",
                   "aWidth": 0.3,
                   "aOptions": ["Male", "Female", "Other"],
                   "aLayout": 'vert'}
     self.questions.append(self.genderItem)
     # then a set of ratings
     items = ["running", "cake"]
     for item in items:
         entry = {"qText": "How much do you like {}".format(item),
                  "qWidth": 0.7,
                  "aType": "rating",
                  "aWidth": 0.3,
                  "aOptions": ["Lots", "Not a lot"],
                  "aLayout": 'horiz'}
         self.questions.append(entry)
     self.survey = Form(self.win, items=self.questions, size=(1.0, 0.3), pos=(0.0, 0.0))
Ejemplo n.º 5
0
from psychopy import core
from psychopy import misc
from psychopy.visual.windowwarp import Warper
from psychopy.monitors import Monitor
from psychopy.visual.grating import GratingStim
from psychopy.visual.window import Window

mon = Monitor('GenericMonitor', width=33.169, distance=10)
mon.setSizePix((1440, 900))
win = Window((1440, 900),
             monitor=mon,
             fullscr=True,
             useFBO=True,
             allowStencil=True)
warper = Warper(win, warp='spherical', warpGridsize=300, eyepoint=[0.5, 0.5])
stim = GratingStim(win=win,
                   units='deg',
                   tex='sin',
                   sf=0.1,
                   size=misc.pix2deg(win.size, win.monitor))
print win.size
print 'win size', win.size
print 'mon size', win.monitor.getSizePix()
print 'as deg', misc.pix2deg(win.size, win.monitor)
stim.draw()
win.flip()
core.wait(0.5)
win.close()
Ejemplo n.º 6
0
from __future__ import print_function

from psychopy import iohub
from psychopy.visual.window import Window
from psychopy.visual.circle import Circle

io = iohub.launchHubServer()
mouse = io.devices.mouse

win = Window(units='pix', fullscr=True)
circle = Circle(win, size=300)
circle.draw()
win.flip()

mouse.clearEvents()

while True:
    e = mouse.getEvents(event_type=(iohub.EventConstants.MOUSE_BUTTON_PRESS))

    if e:
        x, y = e[0].x_position, e[0].y_position

        if circle.contains((x, y), units='pix'):
            print('Received button press!')
            break

win.close()
io.quit()
Ejemplo n.º 7
0
 def setup_class(self):
     self.win = Window([128, 128],
                       pos=[50, 50],
                       allowGUI=False,
                       autoLog=False)
Ejemplo n.º 8
0
def test_open_glfw_window():
    from psychopy.visual.window import Window
    win = Window(winType='glfw', autoLog=False)
    assert win.winType == 'glfw'
    win.flip()
    win.close()
Ejemplo n.º 9
0
def test_open_glfw_window():
    win = Window(winType='glfw', autoLog=False)
    assert win.winType == 'glfw'
    win.flip()
    win.close()