sandbox_app.py 793 B

123456789101112131415161718192021222324252627282930
  1. from __future__ import annotations
  2. from imgui_bundle import imgui, immapp, hello_imgui
  3. import time
  4. start = time.time()
  5. def gui():
  6. imgui.text("Hello world")
  7. imgui.text(f"FPS = {hello_imgui.frame_rate()}")
  8. remaining = 5 - (time.time() - start)
  9. imgui.text(f"Remaining = {remaining:.2f} sec")
  10. now = time.time()
  11. if (now - start) > 5:
  12. hello_imgui.get_runner_params().app_shall_exit = True
  13. def main():
  14. runner_params = hello_imgui.RunnerParams()
  15. # Demo / how to use null backend
  16. # runner_params.platform_backend_type = hello_imgui.PlatformBackendType.null
  17. # runner_params.renderer_backend_type = hello_imgui.RendererBackendType.null
  18. runner_params.callbacks.show_gui = gui
  19. immapp.run(runner_params)
  20. if __name__ == "__main__":
  21. main()