You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows10 64位Spyder3.6中PsychoPy评分量表代码无鼠标点击响应求助

Hey there! I’ve run into similar quirks when running PsychoPy code outside its standalone app, so let’s break down why your rating scale isn’t responding to clicks in Spyder 3.6 on Windows 10 64-bit—and how to fix it.

Top Possible Causes & Solutions

1. You’re Missing an Explicit Event Loop

PsychoPy’s standalone app handles event listening automatically behind the scenes, but Spyder doesn’t do that for you. If your code just draws the rating scale and doesn’t actively check for mouse input, it’ll never register clicks.

Add a loop that continuously listens for mouse events and refreshes the window:

# After creating your ratingScale and window
while True:
    # Check if any mouse button was clicked
    if any(event.getMouseButtons()):
        # Grab the rating if the user clicked the scale
        user_rating = ratingScale.getRating()
        if user_rating is not None:
            print(f"User rating: {user_rating}")
            break  # Exit loop once we have a rating
    
    # Let users quit with the escape key
    if event.getKeys(keyList=['escape']):
        core.quit()
    
    # Refresh the window to update visuals/capture input
    win.flip()

2. Backend Conflicts Between Spyder and PsychoPy

Spyder uses Qt by default, and this can clash with PsychoPy’s window rendering backend. Try forcing PsychoPy to use the pyglet backend when creating your window—it’s often more stable in external IDEs:

win = visual.Window(
    size=(800, 600),
    winType='pyglet',  # Switch to pyglet backend
    monitor='testMonitor',
    color=[0, 0, 0]
)

3. Incomplete Imports or Window Cleanup

Double-check that you’ve imported all necessary PsychoPy modules, especially core—it’s easy to forget, and missing it can break event handling:

from psychopy import visual, event, core  # Make sure core is included

Also, always clean up after your experiment to avoid leaving processes hanging:

win.close()
core.quit()

4. Spyder’s Internal Console is Blocking Input

Spyder’s built-in console sometimes buffers output or interferes with real-time input processing. Try running your script in an external terminal instead:

  • Go to Run > Configuration per file
  • Check the box for Execute in an external system terminal
  • This isolates your script from Spyder’s internal environment and often fixes input lag/unresponsiveness

内容的提问来源于stack exchange,提问作者Ravi Mevada

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:07:41