From 79f612cb316dbcc16620cbc1c20f71e3bda28af6 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Mon, 9 Dec 2024 16:23:14 +0100 Subject: [PATCH] Remove run function (#42) --- docs/backends.rst | 2 +- examples/cube_qt.py | 4 ++-- examples/events.py | 4 ++-- rendercanvas/auto.py | 1 - rendercanvas/glfw.py | 1 - rendercanvas/jupyter.py | 1 - rendercanvas/offscreen.py | 1 - rendercanvas/qt.py | 1 - rendercanvas/stub.py | 1 - rendercanvas/wx.py | 1 - tests/test_backends.py | 2 -- 11 files changed, 5 insertions(+), 14 deletions(-) diff --git a/docs/backends.rst b/docs/backends.rst index 8af0186..03cfc0a 100644 --- a/docs/backends.rst +++ b/docs/backends.rst @@ -241,4 +241,4 @@ glfw if asyncio is enabled or Qt if a qt app is running. On an interactive session without GUI support, one must call ``loop.run()`` to make the canvases interactive. This enters the main loop, which prevents entering new code. Once all canvases are closed, the loop returns. If you make new canvases -afterwards, you can call ``run()`` again. This is similar to ``plt.show()`` in Matplotlib. +afterwards, you can call ``loop.run()`` again. This is similar to ``plt.show()`` in Matplotlib. diff --git a/examples/cube_qt.py b/examples/cube_qt.py index faf7080..2530f8d 100644 --- a/examples/cube_qt.py +++ b/examples/cube_qt.py @@ -21,7 +21,7 @@ pass -from rendercanvas.qt import RenderCanvas, run +from rendercanvas.qt import RenderCanvas, loop from rendercanvas.utils.cube import setup_drawing_sync @@ -31,4 +31,4 @@ if __name__ == "__main__": - run() + loop.run() diff --git a/examples/events.py b/examples/events.py index 27edf56..262aad5 100644 --- a/examples/events.py +++ b/examples/events.py @@ -5,7 +5,7 @@ A simple example to demonstrate events. """ -from rendercanvas.auto import RenderCanvas, run +from rendercanvas.auto import RenderCanvas, loop canvas = RenderCanvas(title="RenderCanvas events") @@ -18,4 +18,4 @@ def process_event(event): if __name__ == "__main__": - run() + loop.run() diff --git a/rendercanvas/auto.py b/rendercanvas/auto.py index 78da682..2296f64 100644 --- a/rendercanvas/auto.py +++ b/rendercanvas/auto.py @@ -203,4 +203,3 @@ def backends_by_trying_in_order(): module = select_backend() RenderCanvas = module.RenderCanvas loop = module.loop -run = loop.run # backwards compat diff --git a/rendercanvas/glfw.py b/rendercanvas/glfw.py index 09631da..35ef8b1 100644 --- a/rendercanvas/glfw.py +++ b/rendercanvas/glfw.py @@ -563,4 +563,3 @@ def poll_glfw_briefly(poll_time=0.1): # Make available under a name that is the same for all backends loop = loop # default loop is AsyncioLoop RenderCanvas = GlfwRenderCanvas -run = loop.run() # backwards compat diff --git a/rendercanvas/jupyter.py b/rendercanvas/jupyter.py index 99eb7ab..fe77296 100644 --- a/rendercanvas/jupyter.py +++ b/rendercanvas/jupyter.py @@ -120,4 +120,3 @@ def handle_event(self, event): # Make available under a name that is the same for all backends RenderCanvas = JupyterRenderCanvas loop = loop -run = loop.run diff --git a/rendercanvas/offscreen.py b/rendercanvas/offscreen.py index 4327188..513c07c 100644 --- a/rendercanvas/offscreen.py +++ b/rendercanvas/offscreen.py @@ -140,4 +140,3 @@ def _rc_call_later(self, delay, callback): loop = StubLoop() -run = loop.run diff --git a/rendercanvas/qt.py b/rendercanvas/qt.py index c31fa19..7a7ea45 100644 --- a/rendercanvas/qt.py +++ b/rendercanvas/qt.py @@ -585,4 +585,3 @@ def closeEvent(self, event): # noqa: N802 # Make available under a name that is the same for all gui backends RenderWidget = QRenderWidget RenderCanvas = QRenderCanvas -run = loop.run # backwards compat diff --git a/rendercanvas/stub.py b/rendercanvas/stub.py index f96974c..4054d7b 100644 --- a/rendercanvas/stub.py +++ b/rendercanvas/stub.py @@ -133,4 +133,3 @@ def __init__(self, parent=None, **kwargs): # Make available under a common name RenderCanvas = StubRenderCanvas loop = StubLoop() -run = loop.run diff --git a/rendercanvas/wx.py b/rendercanvas/wx.py index 3be6e37..d2625d9 100644 --- a/rendercanvas/wx.py +++ b/rendercanvas/wx.py @@ -525,4 +525,3 @@ def Destroy(self): # noqa: N802 - this is a wx method # Make available under a name that is the same for all gui backends RenderWidget = WxRenderWidget RenderCanvas = WxRenderCanvas -run = loop.run # backwards compat diff --git a/tests/test_backends.py b/tests/test_backends.py index 897143e..b2e0eba 100644 --- a/tests/test_backends.py +++ b/tests/test_backends.py @@ -114,7 +114,6 @@ def check_canvas(self, canvas_class): def get_loop_class(self): assert "loop" in self.names - assert "run" in self.names loop_statement = self.names["loop"] assert isinstance(loop_statement, ast.Assign) @@ -188,7 +187,6 @@ def test_auto_module(): m = Module("auto") assert "RenderCanvas" in m.names assert "loop" in m.names - assert "run" in m.names # %% Test modules that only provide a loop