如何在python中进行可视移动或删除

如何在python中进行可视移动或删除,python,python-2.7,vpython,Python,Python 2.7,Vpython,我不知道如何进行可视移动或删除。要制作一个,我只需: from visual import * sphere (color=color.blue,pos=(0,0,0)) 但这只会产生一个sphere()。如何使其移动或消失?如果您的目标是单次移动,那么您只需更改球体的属性pos(或x、y和z)。要删除球体,只需将其visible属性设置为False和del即可使其不可见 from visual import * s = sphere(color=color.blue) # 'pos=(0

我不知道如何进行可视移动或删除。要制作一个,我只需:

from visual import *
sphere (color=color.blue,pos=(0,0,0))

但这只会产生一个
sphere()
。如何使其移动或消失?

如果您的目标是单次移动,那么您只需更改
球体的属性
pos
(或
x
y
z
)。要删除球体,只需将其
visible
属性设置为
False
del
即可使其不可见

from visual import *

s = sphere(color=color.blue)  # 'pos=(0,0,0)' is the default
# Move the sphere to x=1, y=0, z=0
s.pos = (1, 0, 0)

# Now remove the sphere
s.visible = False
del s
显然,在执行这段代码时,由于删除了球体,您将什么也看不到。如果您想在单击时执行此操作,请尝试查看。如果您想寻找更复杂的东西,我建议您使用wxPython的GUI

此外,如果要制作移动球体的动画,可以使用循环:

从视觉导入*

scene.autoscale = False              # Stop the scene from autoscaling
s = sphere(color=color.blue, x=-10)  # Create the sphere
for n in range(-100,100):
    v.rate(100)                      # Set the loop rate to 100 iterations per second
    s.x = n/10.0                     # Set the x attribute of s to move from -10 to 10

# Now remove the sphere
s.visible = False
del s

如果您的目标是单步移动,则只需更改
球体的属性
pos
(或
x
y
z
)。要删除球体,只需将其
visible
属性设置为
False
del
即可使其不可见

from visual import *

s = sphere(color=color.blue)  # 'pos=(0,0,0)' is the default
# Move the sphere to x=1, y=0, z=0
s.pos = (1, 0, 0)

# Now remove the sphere
s.visible = False
del s
显然,在执行这段代码时,由于删除了球体,您将什么也看不到。如果您想在单击时执行此操作,请尝试查看。如果您想寻找更复杂的东西,我建议您使用wxPython的GUI

此外,如果要制作移动球体的动画,可以使用循环:

从视觉导入*

scene.autoscale = False              # Stop the scene from autoscaling
s = sphere(color=color.blue, x=-10)  # Create the sphere
for n in range(-100,100):
    v.rate(100)                      # Set the loop rate to 100 iterations per second
    s.x = n/10.0                     # Set the x attribute of s to move from -10 to 10

# Now remove the sphere
s.visible = False
del s

这从明天开始:这是医生命令你移动屏幕上的东西,然后是一些东西是的,但是。。。我必须付钱吗我明白了。。。显然,那不是给你的……我有点像个孩子,所以……明天开始:这是医生命令你移动屏幕上的东西,然后是一些东西。;)是的,但是。。。我必须付钱吗我明白了。。。显然,那不是给你的…我有点像个孩子所以。。。