python - Psychopy记录最后一次鼠标滚轮移动的时间

标签 python psychopy scrollwheel

我需要记录每次试验最后一次移动滚轮的时间。我有针对按键执行此操作的代码(lastTrialTime 变量):

 lastTime = 0 # setting up to get RT at last key press
    while timer.getTime() >0: # while time isn't up (turns neg when time's up)
        for key in event.getKeys():
            if key in ['escape']:
                core.quit() # quit if they press escape
            if key in ['b']:
            # add keypress to list for each keypress. then move cursor proportionally to length of this list
                b_list.append(key)
                prevPos+=len(b_list)
                lastTime = clock.getTime()
            if key in ['t']:
                t_list.append(key)
                prevPos-=len(t_list)
                lastTime = clock.getTime()
        lastTrialTime = lastTime

但我不知道如何对鼠标响应进行操作。我使用以下代码行来获取每次刷新时滚轮移动的距离。

wheel_dX, wheel_dY = myMouse.getWheelRel()*4

但是,我不知道如何使用它(或其他东西?)来创建一个包含最后一次滚轮移动的 clock.getTime() 调用的变量。

最佳答案

您可以测试值是否为0:

wheel_dX, wheel_dY = myMouse.getWheelRel()*4
if any([wheel_dX, wheel_dY]):
    lastTime = clock.getTime()

关于python - Psychopy记录最后一次鼠标滚轮移动的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34233083/

相关文章:

python - SQLAlchemy:获取具有最新日期的对象

python - 不同的心理持续时间

python - 保存图形及其框架,matplotlib

python - 将 subprocess.Popen 的标准输出逐行保存到文件

python - 如何知道客户端在套接字中断开服务器连接

python - 使用 MovieStim2 在 PsychoPy 中基于按键跳过视频(循环)

python - 线程停止应用程序

numbers - 垂直滚动值在重新启动/注销时重置

c# - 鼠标滚轮输入无法统一识别