gpt4 book ai didi

python - 无论鼠标单击如何,psychopy 鼠标跟踪都会返回 true

转载 作者:太空宇宙 更新时间:2023-11-04 05:14:17 27 4
gpt4 key购买 nike

我正在尝试 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")

最佳答案

mouse.getPressed() 返回一个包含 3 个元素的元组,表示按下的鼠标按钮,因此 (1, 0, 0) 表示左键被按下按下 s 你的代码应该是这样的:

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")

关于python - 无论鼠标单击如何,psychopy 鼠标跟踪都会返回 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42164317/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com