Beispiel #1
0
    def test_stop_running__raises_if_not_running(self):
        gui = GUI()
        with self.assertRaises(RuntimeError):
            gui.stop_running()

        # Also make sure it raises if the GUI ran in the past, but then stopped.
        with self.running_in_background(gui):
            pass
        with self.assertRaises(RuntimeError):
            gui.stop_running()
Beispiel #2
0
  def test_stop_running__raises_if_not_running(self):
    gui = GUI()
    with self.assertRaises(RuntimeError):
      gui.stop_running()

    # Also make sure it raises if the GUI ran in the past, but then stopped.
    with self.running_in_background(gui):
      pass
    with self.assertRaises(RuntimeError):
      gui.stop_running()
def main():
  gui = GUI(Paragraph("""
    Run commands in the REPL.
    As you change `gui`, this page will update.
    Some commands you might run are:
  """))

  for sample in ("gui.body.append(Text('Hiiii!'))",
                 "gui.body.append(Button(callback=(lambda: gui.body.append(Paragraph('Clicked!')))))"):
    gui.body.append(CodeBlock(sample))

  t = threading.Thread(target=gui.run, kwargs={'quiet': True})
  t.daemon = True
  t.start()
  run_repl(gui)

  if gui.running: # If the user killed the GUI in the REPL, it might not still be running.
    gui.stop_running()