【问题标题】:how to stop Vpython from being unresponsive如何阻止 Vpython 无响应
【发布时间】:2017-01-25 13:16:29
【问题描述】:

我对 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()

【问题讨论】:

  • 当你暂停程序时,它实际上退出了,因为退出了“循环”。
  • @m00lti ,好的,你能告诉我如何阻止这种情况发生吗?我如何让它暂停而不退出循环?

标签: button simulation vpython


【解决方案1】:

我不确定,因为我不太了解您的代码,但重复循环需要包含 rate 语句。否则程序会死机,无法输出任何东西。

【讨论】:

    猜你喜欢
    • 2021-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-23
    • 2017-05-10
    • 2023-01-23
    • 2013-07-18
    • 2013-07-19
    相关资源
    最近更新 更多