Python spyder 3.6:程序不接受鼠标点击

时间:2018-04-16 09:58:27

标签: python-3.x mouseevent spyder psychopy

我尝试在python spyder 3.6中运行下面提到的程序,在Windows 10 64位上运行64位。当我运行代码时,它不接受任何鼠标键。我能够移动光标但是当我尝试点击评级时,没有任何事情发生。可能是什么问题呢?此代码是心理学中Demos评级量表计划的第一部分。在心理上,它运行良好。谢谢。

“”“

code: 
from __future__ import division
from __future__ import print_function

from psychopy import visual, event, core, logging
import os

#create a window before creating your rating scale, whatever units you like:
win = visual.Window(fullscr=False, size=[1100, 800], units='pix', monitor='testMonitor')
instr = visual.TextStim(win, text="""This is a demo of  visual.RatingScale(). There are four examples.

#Example 1 is on the next screen. Use the mouse to indicate a rating:   click somewhere on the line. You   can also use the arrow keys to move left or right.

#To accept your rating, either press 'enter' or click the glowing button. Pressing 'tab' will skip the rating.

#Press any key to start Example 1 (or escape to quit).""")

event.clearEvents()
instr.draw()
win.flip()
if 'escape' in event.waitKeys():
    core.quit()

# Example 1 --------(basic choices)--------
# create a RatingScale object:
myRatingScale = visual.RatingScale(win, choices=['cold', 'cool', 'hot'])

# Or try this one:
# myRatingScale = visual.RatingScale(win, choices=map(str, range(1, 8)), marker='hover')

# the item to-be-rated or respond to:
myItem = visual.TextStim(win, text="How cool was that?", height=.12, units='norm')

# anything with a frame-by-frame .draw() method will work, e.g.:
# myItem = visual.MovieStim(win, 'jwpIntro.mov')

event.clearEvents()
while myRatingScale.noResponse:  # show & update until a response has been made
myItem.draw()
myRatingScale.draw()
win.flip()
if event.getKeys(['escape']):
core.quit()

print('Example 1: rating =', myRatingScale.getRating())
print('history =', myRatingScale.getHistory())

当我按下'escape'键时,窗口没有关闭。我也回过头来。

runfile('C:/Users/ravikumar.mevada/Gustometer/qmix/examples/rating2.py', wdir='C:/Users/ravikumar.mevada/Gustometer/qmix/examples')
An exception has occurred, use %tb to see the full traceback.

SystemExit: 0

c:\program files\python36\lib\site-packages\IPython\core\interactiveshell.py:2971: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

0 个答案:

没有答案