这是来自" vpython.org"的简单代码。教程:
from vpython import *
scene = canvas(title='Rubic solver!',
width=800, height=600,
center=vector(5,0,0), background=color.white,userzoom=0,userspin=0,userpan=0)
box()
while True:
ev = scene.waitfor('mousedown mouseup')
print(ev)
if ev.event == 'mousedown':
print('You pressed the mouse button')
else:
print('You released the mouse button')
print(ev.pos) # the position of the mouse
当我打印" ev"输出为None,然后出现错误:
if ev.event == 'mousedown':
AttributeError: 'NoneType' object has no attribute 'event'
注意:我使用的是Vpython7和Python3.6。
答案 0 :(得分:0)
此错误已在VPython 7中修复。您发布的示例有效。
对于VPython问题,最好发布到VPython论坛,在那里有更多的VPython用户会看到你的问题而不是你发布到stackoverflow:
https://groups.google.com/forum/?fromgroups&hl=en#!forum/vpython-users