我正在尝试使用psychopy的鼠标跟踪功能。对于初学者,我只想记录是否发生鼠标点击。即使我没有点击鼠标,它也会打印“按下”。我使用的是v1.84.2。
from psychopy import core, visual, gui, data, misc, event, sound
import time, random, math, os
import numpy as np
import copy
from pygame import mouse, locals, display
screenSize =[1280, 800]
win = visual.Window(size = screenSize, fullscr = True, allowGUI=False, monitor='testMonitor', units='deg')
mouse = event.Mouse(visible=True, newPos=[0,0])
mouse.clickReset()
if mouse.getPressed():
print ("got pressed")
答案 0 :(得分:1)
mouse.getPressed()
返回一个由3个元素组成的元组,表示按下了什么鼠标按钮,因此(1, 0, 0)
表示正在按下左键,你的代码应如下所示:
from psychopy import core, visual, gui, data, misc, event, sound
import time, random, math, os
import numpy as np
import copy
from pygame import mouse, locals, display
screenSize =[1280, 800]
win = visual.Window(size = screenSize, fullscr = True, allowGUI=False, monitor='testMonitor', units='deg')
mouse = event.Mouse(visible=True, newPos=[0,0])
mouse.clickReset()
if mouse.getPressed()[0]:
print ("got pressed")