Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Button 如何阻止Vpython没有反应_Button_Simulation_Vpython - Fatal编程技术网

Button 如何阻止Vpython没有反应

Button 如何阻止Vpython没有反应,button,simulation,vpython,Button,Simulation,Vpython,我是Vpython的新手,我创建了一个圆周运动的模拟。我尝试将控件添加到模拟中,到目前为止,我可以暂停模拟,但当我暂停模拟时,整个控制面板将失去响应,我无法恢复模拟。有人知道为什么会这样,或者我如何解决这个问题吗 def playorpause(self, goorno): self.pause = goorno def actual_sim(self): c = controls() # Create controls window # Create a but

我是Vpython的新手,我创建了一个圆周运动的模拟。我尝试将控件添加到模拟中,到目前为止,我可以暂停模拟,但当我暂停模拟时,整个控制面板将失去响应,我无法恢复模拟。有人知道为什么会这样,或者我如何解决这个问题吗

 def playorpause(self, goorno):
    self.pause = goorno

def actual_sim(self):

    c = controls()  # Create controls window
    # Create a button in the controls window:

    # b = Button(pos=(-50, 0), width=60, height=60, text="Pause", action=lambda: self.change)
    # play = Button(pos=(50, 0), width=60, height=60, text="Play", command = self.play_sim)

    b = button(pos=(-50, 0), width=60, height=60, text='Pause', action=lambda: self.playorpause(True))
    play = button(pos=(50,0), width = 60, height = 60, text = "play", action =lambda: self.playorpause(False))

  def loop():
#### simulation code
        if self.pause == False:
            loop()

我不确定,因为我不太理解您的代码,但是重复循环需要包含一个rate语句。否则程序将锁定,无法输出任何内容。

当您暂停程序时,它实际上会退出,因为“循环”已退出。@m00lti,好的,您能告诉我如何阻止这种情况发生吗。如何使其在不退出循环的情况下暂停?