psychopy.org | Reference | Downloads | Github

Custom mouse and degFlat or degFlatPos

Hoping for a bit of advice on using degFlat or degFlatPos.

It works fine except when I want to use a custom mouse (visual.CustomMouse). I was wondering if anyone else had had any success with using these two together?

EXAMPLE BELOW

Thanks,
Pete

For example, quick modification of the customMouse.py demo:

from psychopy import visual, event, monitors
mon = monitors.Monitor('TVscreen1')
mon.setDistance(30)
mon.setSizePix([1920,1080])
mon.setWidth(40)
myWin = visual.Window(units='degFlat', monitor=mon)
vm = visual.CustomMouse(myWin, leftLimit=-0.2, topLimit=0, rightLimit=0.2, bottomLimit=-0.4, 
            showLimitBox=True, clickOnUp=True)
instr = visual.TextStim(myWin,text="move the mouse around.\nclick to give the mouse more room to move.", pos=(0,.3))
new_pointer = visual.TextStim(myWin, text='o')
print("[getPos] [getWheelRel] click time")
while not event.getKeys():
    instr.draw()
    vm.draw()
    myWin.flip()
    if vm.getClicks():
        vm.resetClicks()
        #vm.setVisible(not vm.getVisible()) # can use get & set; here, a click toggles mouse visibility
        print("click at [%.2f, %.2f]" % (vm.getPos()[0],vm.getPos()[1]))
        print(vm.getWheelRel())
        print("%.3f sec"%vm.mouseMoveTime())
        vm.setLimit(leftLimit = -0.7, rightLimit = 0.7, bottomLimit = -0.8) # can set some limits, others are unchanged
        instr.setText("any key to quit")
        vm.pointer = new_pointer # switch the pointer appearance to anything with a .draw() and setPos() method

Gives this error:

[getPos] [getWheelRel] click time
Traceback (most recent call last):
  File "C:\Users\Peter\Desktop\customMouse1.py", line 23, in <module>
    vm.draw()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.83.04-py2.7.egg\psychopy\visual\custommouse.py", line 153, in draw
    self._setPos()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.83.04-py2.7.egg\psychopy\visual\custommouse.py", line 133, in _setPos
    pos = self.getPos()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.83.04-py2.7.egg\psychopy\visual\custommouse.py", line 145, in getPos
    dx, dy = self.getRel()
TypeError: 'NoneType' object is not iterable

The short answer is that I don’t think this is supported