From c2222a00d76b27822e3cdef6cf1318c920be2f67 Mon Sep 17 00:00:00 2001 From: Marouane743 Date: Thu, 14 Nov 2024 20:51:20 +0100 Subject: [PATCH] Enhancement: Add optional view argument to Window.run() and pass to arcade.run() --- arcade/application.py | 4 ++-- arcade/window_commands.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arcade/application.py b/arcade/application.py index 6a748d7505..63ad5294ac 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -402,7 +402,7 @@ def rect(self) -> Rect: """Return a Rect describing the size of the window.""" return LBWH(0, 0, self.width, self.height) - def run(self) -> None: + def run(self, view=None) -> None: """ Run the event loop. @@ -411,7 +411,7 @@ def run(self) -> None: function starting pyglet's event loop meaning it will start to dispatch events such as ``on_draw`` and ``on_update``. """ - arcade.run() + arcade.run(view=view) def close(self) -> None: """Close the Window.""" diff --git a/arcade/window_commands.py b/arcade/window_commands.py index f4d1c22718..db836d6234 100644 --- a/arcade/window_commands.py +++ b/arcade/window_commands.py @@ -97,7 +97,7 @@ def close_window() -> None: gc.collect() -def run(): +def run(view=None): """ Run the main loop. @@ -108,6 +108,10 @@ def run(): """ window = get_window() + # Show the provided view if specified + if view is not None: + window.show_view(view) + # Used in some unit test if os.environ.get("ARCADE_TEST"): window.on_update(1.0 / 60.0)