From 94b4f37882f97d4de55677d235394f2a187e7def Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 6 Nov 2024 09:50:26 +0100 Subject: [PATCH 1/8] Rename WgpuCanvas -> RenderCanvas --- docs/gui.rst | 38 ++++++++++++++++++------------------ docs/guide.rst | 4 ++-- examples/gui_auto.py | 6 +++--- examples/gui_demo.py | 4 ++-- examples/gui_events.py | 4 ++-- examples/gui_glfw.py | 4 ++-- examples/gui_multiple.py | 6 +++--- examples/gui_qt.py | 4 ++-- examples/gui_threading.py | 4 ++-- examples/gui_wx.py | 4 ++-- rendercanvas/__init__.py | 6 +++--- rendercanvas/_events.py | 2 +- rendercanvas/auto.py | 6 +++--- rendercanvas/base.py | 8 ++++---- rendercanvas/glfw.py | 6 +++--- rendercanvas/jupyter.py | 10 +++++----- rendercanvas/offscreen.py | 6 +++--- rendercanvas/qt.py | 12 ++++++------ rendercanvas/utils/cube.py | 4 ++-- rendercanvas/wx.py | 12 ++++++------ tests/test_gui_base.py | 14 ++++++------- tests/test_gui_glfw.py | 18 ++++++++--------- tests/test_gui_offscreen.py | 8 ++++---- tests/test_gui_scheduling.py | 4 ++-- 24 files changed, 97 insertions(+), 97 deletions(-) diff --git a/docs/gui.rst b/docs/gui.rst index fa55c02..8b305ec 100644 --- a/docs/gui.rst +++ b/docs/gui.rst @@ -13,8 +13,8 @@ moment these include GLFW, Jupyter, Qt, and wx. The Canvas base classes ----------------------- -For each supported GUI toolkit there is a module that implements a ``WgpuCanvas`` class, -which inherits from :class:`WgpuCanvasBase`, providing a common API. +For each supported GUI toolkit there is a module that implements a ``RenderCanvas`` class, +which inherits from :class:`BaseRenderCanvas`, providing a common API. The GLFW, Qt, and Jupyter backends also inherit from :class:`WgpuAutoGui` to include support for events (interactivity). In the next sections we demonstrates the different canvas classes that you can use. @@ -23,7 +23,7 @@ canvas classes that you can use. Events ------ -To implement interaction with a ``WgpuCanvas``, use the :func:`WgpuCanvasBase.add_event_handler()` method. +To implement interaction with a ``RenderCanvas``, use the :func:`BaseRenderCanvas.add_event_handler()` method. Events come in the following flavours: .. autoclass:: WgpuEventType @@ -47,9 +47,9 @@ for details about the event objects. .. code-block:: py - from wgpu.gui.auto import WgpuCanvas, run, call_later + from wgpu.gui.auto import RenderCanvas, run, call_later - canvas = WgpuCanvas(title="Example") + canvas = RenderCanvas(title="Example") canvas.request_draw(your_draw_function) run() @@ -64,9 +64,9 @@ but you can replace ``from rendercanvas.auto`` with ``from rendercanvas.glfw`` t .. code-block:: py - from wgpu.gui.glfw import WgpuCanvas, run, call_later + from wgpu.gui.glfw import RenderCanvas, run, call_later - canvas = WgpuCanvas(title="Example") + canvas = RenderCanvas(title="Example") canvas.request_draw(your_draw_function) run() @@ -77,7 +77,7 @@ Support for Qt There is support for PyQt5, PyQt6, PySide2 and PySide6. The rendercanvas library detects what library you are using by looking what module has been imported. -For a toplevel widget, the ``rendercanvas.qt.WgpuCanvas`` class can be imported. If you want to +For a toplevel widget, the ``rendercanvas.qt.RenderCanvas`` class can be imported. If you want to embed the canvas as a subwidget, use ``rendercanvas.qt.WgpuWidget`` instead. Also see the `Qt triangle example `_ @@ -85,15 +85,15 @@ and `Qt triangle embed example `_ @@ -114,12 +114,12 @@ and `wx triangle embed example `. + In most cases it's more convenient to subclass :class:`BaseRenderCanvas `. """ _canvas_context = None # set in get_context() @@ -83,7 +83,7 @@ def present_image(self, image, **kwargs): raise NotImplementedError() -class WgpuCanvasBase(WgpuCanvasInterface): +class BaseRenderCanvas(RenderCanvasInterface): """The base canvas class. This class provides a uniform canvas API so render systems can be use @@ -371,7 +371,7 @@ def _set_title(self, title): def pop_kwargs_for_base_canvas(kwargs_dict): """Convenience functions for wrapper canvases like in Qt and wx.""" - code = WgpuCanvasBase.__init__.__code__ + code = BaseRenderCanvas.__init__.__code__ base_kwarg_names = code.co_varnames[: code.co_argcount + code.co_kwonlyargcount] d = {} for key in base_kwarg_names: diff --git a/rendercanvas/glfw.py b/rendercanvas/glfw.py index d116c51..442418f 100644 --- a/rendercanvas/glfw.py +++ b/rendercanvas/glfw.py @@ -14,7 +14,7 @@ import glfw -from .base import WgpuCanvasBase +from .base import BaseRenderCanvas from .asyncio import AsyncioWgpuLoop from ._gui_utils import SYSTEM_IS_WAYLAND, weakbind, logger @@ -141,7 +141,7 @@ def get_physical_size(window): return int(psize[0]), int(psize[1]) -class GlfwWgpuCanvas(WgpuCanvasBase): +class GlfwRenderCanvas(BaseRenderCanvas): """A glfw window providing a wgpu canvas.""" # See https://www.glfw.org/docs/latest/group__window.html @@ -523,7 +523,7 @@ def present_image(self, image, **kwargs): # Make available under a name that is the same for all gui backends -WgpuCanvas = GlfwWgpuCanvas +RenderCanvas = GlfwRenderCanvas class GlfwAsyncioWgpuLoop(AsyncioWgpuLoop): diff --git a/rendercanvas/jupyter.py b/rendercanvas/jupyter.py index 5f22762..de58d7f 100644 --- a/rendercanvas/jupyter.py +++ b/rendercanvas/jupyter.py @@ -6,7 +6,7 @@ import time import weakref -from .base import WgpuCanvasBase +from .base import BaseRenderCanvas from .asyncio import AsyncioWgpuLoop import numpy as np @@ -14,7 +14,7 @@ from IPython.display import display -class JupyterWgpuCanvas(WgpuCanvasBase, RemoteFrameBuffer): +class JupyterRenderCanvas(BaseRenderCanvas, RemoteFrameBuffer): """An ipywidgets widget providing a wgpu canvas. Needs the jupyter_rfb library.""" def __init__(self, *, size=None, title=None, **kwargs): @@ -62,7 +62,7 @@ def get_frame(self): self._draw_frame_and_present() return self._last_image - # Implementation needed for WgpuCanvasBase + # Implementation needed for BaseRenderCanvas def _get_loop(self): return loop @@ -105,7 +105,7 @@ def _force_draw(self): if array is not None: self._rfb_send_frame(array) - # Implementation needed for WgpuCanvasInterface + # Implementation needed for RenderCanvasInterface def get_present_info(self): # Use a format that maps well to PNG: rgba8norm. Use srgb for @@ -123,7 +123,7 @@ def present_image(self, image, **kwargs): # Make available under a name that is the same for all gui backends -WgpuCanvas = JupyterWgpuCanvas +RenderCanvas = JupyterRenderCanvas class JupyterAsyncioWgpuLoop(AsyncioWgpuLoop): diff --git a/rendercanvas/offscreen.py b/rendercanvas/offscreen.py index 16c2d05..3da5d1c 100644 --- a/rendercanvas/offscreen.py +++ b/rendercanvas/offscreen.py @@ -1,7 +1,7 @@ -from .base import WgpuCanvasBase, WgpuLoop, WgpuTimer +from .base import BaseRenderCanvas, WgpuLoop, WgpuTimer -class WgpuManualOffscreenCanvas(WgpuCanvasBase): +class WgpuManualOffscreenCanvas(BaseRenderCanvas): """An offscreen canvas intended for manual use. Call the ``.draw()`` method to perform a draw and get the result. @@ -69,7 +69,7 @@ def draw(self): return self._last_image -WgpuCanvas = WgpuManualOffscreenCanvas +RenderCanvas = WgpuManualOffscreenCanvas class StubWgpuTimer(WgpuTimer): diff --git a/rendercanvas/qt.py b/rendercanvas/qt.py index b079862..e2d49f7 100644 --- a/rendercanvas/qt.py +++ b/rendercanvas/qt.py @@ -7,7 +7,7 @@ import ctypes import importlib -from .base import WgpuCanvasBase, WgpuLoop, WgpuTimer, pop_kwargs_for_base_canvas +from .base import BaseRenderCanvas, WgpuLoop, WgpuTimer, pop_kwargs_for_base_canvas from ._gui_utils import ( logger, SYSTEM_IS_WAYLAND, @@ -139,7 +139,7 @@ def enable_hidpi(): ) -class QWgpuWidget(WgpuCanvasBase, QtWidgets.QWidget): +class QWgpuWidget(BaseRenderCanvas, QtWidgets.QWidget): """A QWidget representing a wgpu canvas that can be embedded in a Qt application.""" def __init__(self, *args, present_method=None, **kwargs): @@ -267,7 +267,7 @@ def set_logical_size(self, width, height): if width < 0 or height < 0: raise ValueError("Window width and height must not be negative") parent = self.parent() - if isinstance(parent, QWgpuCanvas): + if isinstance(parent, QRenderCanvas): parent.resize(width, height) else: self.resize(width, height) # See comment on pixel ratio @@ -276,7 +276,7 @@ def _set_title(self, title): # A QWidgets title can actually be shown when the widget is shown in a dock. # But the application should probably determine that title, not us. parent = self.parent() - if isinstance(parent, QWgpuCanvas): + if isinstance(parent, QRenderCanvas): parent.setWindowTitle(title) def close(self): @@ -446,7 +446,7 @@ def present_image(self, image_data, **kwargs): # backingstore.flush(rect2) -class QWgpuCanvas(WgpuCanvasBase, QtWidgets.QWidget): +class QRenderCanvas(BaseRenderCanvas, QtWidgets.QWidget): """A toplevel Qt widget providing a wgpu canvas.""" # Most of this is proxying stuff to the inner widget. @@ -545,7 +545,7 @@ def present_image(self, image, **kwargs): # Make available under a name that is the same for all gui backends WgpuWidget = QWgpuWidget -WgpuCanvas = QWgpuCanvas +RenderCanvas = QRenderCanvas class QtWgpuTimer(WgpuTimer): diff --git a/rendercanvas/utils/cube.py b/rendercanvas/utils/cube.py index 0a66c19..0ed7ac6 100644 --- a/rendercanvas/utils/cube.py +++ b/rendercanvas/utils/cube.py @@ -15,7 +15,7 @@ def setup_drawing_sync(canvas, power_preference="high-performance", limits=None): """Setup to draw a rotating cube on the given canvas. - The given canvas must implement WgpuCanvasInterface, but nothing more. + The given canvas must implement RenderCanvasInterface, but nothing more. Returns the draw function. """ @@ -35,7 +35,7 @@ def setup_drawing_sync(canvas, power_preference="high-performance", limits=None) async def setup_drawing_async(canvas, limits=None): """Setup to async-draw a rotating cube on the given canvas. - The given canvas must implement WgpuCanvasInterface, but nothing more. + The given canvas must implement RenderCanvasInterface, but nothing more. Returns the draw function. """ diff --git a/rendercanvas/wx.py b/rendercanvas/wx.py index 091222b..bc85e01 100644 --- a/rendercanvas/wx.py +++ b/rendercanvas/wx.py @@ -16,7 +16,7 @@ get_alt_x11_display, get_alt_wayland_display, ) -from .base import WgpuCanvasBase, WgpuLoop, WgpuTimer, pop_kwargs_for_base_canvas +from .base import BaseRenderCanvas, WgpuLoop, WgpuTimer, pop_kwargs_for_base_canvas BUTTON_MAP = { @@ -120,7 +120,7 @@ def enable_hidpi(): ) -class WxWgpuWindow(WgpuCanvasBase, wx.Window): +class WxWgpuWindow(BaseRenderCanvas, wx.Window): """A wx Window representing a wgpu canvas that can be embedded in a wx application.""" def __init__(self, *args, present_method=None, **kwargs): @@ -371,7 +371,7 @@ def set_logical_size(self, width, height): if width < 0 or height < 0: raise ValueError("Window width and height must not be negative") parent = self.Parent - if isinstance(parent, WxWgpuCanvas): + if isinstance(parent, WxRenderCanvas): parent.SetSize(width, height) else: self.SetSize(width, height) @@ -379,7 +379,7 @@ def set_logical_size(self, width, height): def _set_title(self, title): # Set title only on frame parent = self.Parent - if isinstance(parent, WxWgpuCanvas): + if isinstance(parent, WxRenderCanvas): parent.SetTitle(title) def _request_draw(self): @@ -417,7 +417,7 @@ def present_image(self, image_data, **kwargs): dc.DrawBitmap(bitmap, 0, 0, False) -class WxWgpuCanvas(WgpuCanvasBase, wx.Frame): +class WxRenderCanvas(BaseRenderCanvas, wx.Frame): """A toplevel wx Frame providing a wgpu canvas.""" # Most of this is proxying stuff to the inner widget. @@ -512,7 +512,7 @@ def present_image(self, image, **kwargs): # Make available under a name that is the same for all gui backends WgpuWidget = WxWgpuWindow -WgpuCanvas = WxWgpuCanvas +RenderCanvas = WxRenderCanvas class TimerWithCallback(wx.Timer): diff --git a/tests/test_gui_base.py b/tests/test_gui_base.py index ed439d7..18aa716 100644 --- a/tests/test_gui_base.py +++ b/tests/test_gui_base.py @@ -12,11 +12,11 @@ def test_base_canvas_context(): - assert hasattr(rendercanvas.WgpuCanvasInterface, "get_context") + assert hasattr(rendercanvas.RenderCanvasInterface, "get_context") def test_canvas_get_context_needs_backend_to_be_selected(): - code = "from rendercanvas import WgpuCanvasBase; canvas = WgpuCanvasBase(); canvas.get_context()" + code = "from rendercanvas import BaseRenderCanvas; canvas = BaseRenderCanvas(); canvas.get_context()" result = subprocess.run( [sys.executable, "-c", code], @@ -31,7 +31,7 @@ def test_canvas_get_context_needs_backend_to_be_selected(): assert "canvas.get_context" in out.lower() -class CanvasThatRaisesErrorsDuringDrawing(rendercanvas.WgpuCanvasBase): +class CanvasThatRaisesErrorsDuringDrawing(rendercanvas.BaseRenderCanvas): def __init__(self): super().__init__() self._count = 0 @@ -91,7 +91,7 @@ def test_canvas_logging(caplog): assert text.count("intended-fail") == 4 -class MyOffscreenCanvas(rendercanvas.WgpuCanvasBase): +class MyOffscreenCanvas(rendercanvas.BaseRenderCanvas): def __init__(self): super().__init__() self.frame_count = 0 @@ -123,8 +123,8 @@ def test_run_bare_canvas(): # This is (more or less) the equivalent of: # - # from rendercanvas.auto import WgpuCanvas, loop - # canvas = WgpuCanvas() + # from rendercanvas.auto import RenderCanvas, loop + # canvas = RenderCanvas() # loop.run() # # Note: loop.run() calls _draw_frame_and_present() in event loop. @@ -202,7 +202,7 @@ def draw_frame(): def test_canvas_base_events(): - c = rendercanvas.WgpuCanvasBase() + c = rendercanvas.BaseRenderCanvas() # We test events extensively in another test module. This is just # to make sure that events are working for the base canvas. diff --git a/tests/test_gui_glfw.py b/tests/test_gui_glfw.py index a1aa0b8..0f683e1 100644 --- a/tests/test_gui_glfw.py +++ b/tests/test_gui_glfw.py @@ -31,19 +31,19 @@ def teardown_module(): def test_is_canvas_base(): - from rendercanvas import WgpuCanvasBase - from rendercanvas.glfw import WgpuCanvas + from rendercanvas import BaseRenderCanvas + from rendercanvas.glfw import RenderCanvas - assert issubclass(WgpuCanvas, WgpuCanvasBase) + assert issubclass(RenderCanvas, BaseRenderCanvas) def test_glfw_canvas_basics(): """Create a window and check some of its behavior. No wgpu calls here.""" import glfw - from rendercanvas.glfw import WgpuCanvas + from rendercanvas.glfw import RenderCanvas - canvas = WgpuCanvas() + canvas = RenderCanvas() canvas.set_logical_size(300, 200) etime = time.time() + 0.1 @@ -65,14 +65,14 @@ def test_glfw_canvas_basics(): def test_glfw_canvas_del(): - from rendercanvas.glfw import WgpuCanvas, loop + from rendercanvas.glfw import RenderCanvas, loop def run_briefly(): asyncio_loop = loop._loop asyncio_loop.run_until_complete(asyncio.sleep(0.5)) # poll_glfw_briefly() - canvas = WgpuCanvas() + canvas = RenderCanvas() ref = weakref.ref(canvas) assert ref() is not None @@ -104,14 +104,14 @@ def test_glfw_canvas_render(): import wgpu import glfw - from rendercanvas.glfw import WgpuCanvas, loop + from rendercanvas.glfw import RenderCanvas, loop def run_briefly(): asyncio_loop = loop._loop asyncio_loop.run_until_complete(asyncio.sleep(0.5)) # poll_glfw_briefly() - canvas = WgpuCanvas(max_fps=9999, update_mode="ondemand") + canvas = RenderCanvas(max_fps=9999, update_mode="ondemand") device = wgpu.gpu.request_adapter_sync().request_device_sync() draw_frame1 = _get_draw_function(device, canvas) diff --git a/tests/test_gui_offscreen.py b/tests/test_gui_offscreen.py index 0b83d96..b01e6d7 100644 --- a/tests/test_gui_offscreen.py +++ b/tests/test_gui_offscreen.py @@ -23,12 +23,12 @@ def test_offscreen_selection_using_env_var(): for value in ["", "0", "false", "False", "wut"]: os.environ["WGPU_FORCE_OFFSCREEN"] = value module = select_backend() - assert module.WgpuCanvas is not WgpuManualOffscreenCanvas + assert module.RenderCanvas is not WgpuManualOffscreenCanvas for value in ["1", "true", "True"]: os.environ["WGPU_FORCE_OFFSCREEN"] = value module = select_backend() - assert module.WgpuCanvas is WgpuManualOffscreenCanvas + assert module.RenderCanvas is WgpuManualOffscreenCanvas finally: os.environ["WGPU_FORCE_OFFSCREEN"] = ori @@ -53,9 +53,9 @@ def check(): def test_offscreen_canvas_del(): - from rendercanvas.offscreen import WgpuCanvas + from rendercanvas.offscreen import RenderCanvas - canvas = WgpuCanvas() + canvas = RenderCanvas() ref = weakref.ref(canvas) assert ref() is not None diff --git a/tests/test_gui_scheduling.py b/tests/test_gui_scheduling.py index 5938684..9a6174c 100644 --- a/tests/test_gui_scheduling.py +++ b/tests/test_gui_scheduling.py @@ -6,7 +6,7 @@ import time from testutils import run_tests -from rendercanvas import WgpuCanvasBase, WgpuLoop, WgpuTimer +from rendercanvas import BaseRenderCanvas, WgpuLoop, WgpuTimer class MyTimer(WgpuTimer): @@ -36,7 +36,7 @@ def _stop(self): self.__stopped = True -class MyCanvas(WgpuCanvasBase): +class MyCanvas(BaseRenderCanvas): _loop = MyLoop() _gui_draw_requested = False From 8aba1bf43049906fc154979487d471965240fe3e Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 6 Nov 2024 10:07:02 +0100 Subject: [PATCH 2/8] Rename examples --- examples/{gui_auto.py => cube_auto.py} | 0 examples/{gui_glfw.py => cube_glfw.py} | 0 examples/{gui_qt.py => cube_qt.py} | 0 examples/{gui_wx.py => cube_wx.py} | 0 examples/{gui_demo.py => demo.py} | 0 examples/{gui_events.py => events.py} | 0 examples/{gui_multiple.py => multiple.py} | 0 examples/{gui_threading.py => offsceen_threaded.py} | 0 examples/{gui_qt_embed.py => qt_app.py} | 0 examples/{gui_qt_asyncio.py => qt_app_asyncio.py} | 0 examples/{gui_wx_embed.py => wx_app.py} | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename examples/{gui_auto.py => cube_auto.py} (100%) rename examples/{gui_glfw.py => cube_glfw.py} (100%) rename examples/{gui_qt.py => cube_qt.py} (100%) rename examples/{gui_wx.py => cube_wx.py} (100%) rename examples/{gui_demo.py => demo.py} (100%) rename examples/{gui_events.py => events.py} (100%) rename examples/{gui_multiple.py => multiple.py} (100%) rename examples/{gui_threading.py => offsceen_threaded.py} (100%) rename examples/{gui_qt_embed.py => qt_app.py} (100%) rename examples/{gui_qt_asyncio.py => qt_app_asyncio.py} (100%) rename examples/{gui_wx_embed.py => wx_app.py} (100%) diff --git a/examples/gui_auto.py b/examples/cube_auto.py similarity index 100% rename from examples/gui_auto.py rename to examples/cube_auto.py diff --git a/examples/gui_glfw.py b/examples/cube_glfw.py similarity index 100% rename from examples/gui_glfw.py rename to examples/cube_glfw.py diff --git a/examples/gui_qt.py b/examples/cube_qt.py similarity index 100% rename from examples/gui_qt.py rename to examples/cube_qt.py diff --git a/examples/gui_wx.py b/examples/cube_wx.py similarity index 100% rename from examples/gui_wx.py rename to examples/cube_wx.py diff --git a/examples/gui_demo.py b/examples/demo.py similarity index 100% rename from examples/gui_demo.py rename to examples/demo.py diff --git a/examples/gui_events.py b/examples/events.py similarity index 100% rename from examples/gui_events.py rename to examples/events.py diff --git a/examples/gui_multiple.py b/examples/multiple.py similarity index 100% rename from examples/gui_multiple.py rename to examples/multiple.py diff --git a/examples/gui_threading.py b/examples/offsceen_threaded.py similarity index 100% rename from examples/gui_threading.py rename to examples/offsceen_threaded.py diff --git a/examples/gui_qt_embed.py b/examples/qt_app.py similarity index 100% rename from examples/gui_qt_embed.py rename to examples/qt_app.py diff --git a/examples/gui_qt_asyncio.py b/examples/qt_app_asyncio.py similarity index 100% rename from examples/gui_qt_asyncio.py rename to examples/qt_app_asyncio.py diff --git a/examples/gui_wx_embed.py b/examples/wx_app.py similarity index 100% rename from examples/gui_wx_embed.py rename to examples/wx_app.py From 0b7fc3986925132e20f06d153f9fd81a077cd158 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 6 Nov 2024 10:08:31 +0100 Subject: [PATCH 3/8] Rename tests --- tests/{test_gui_base.py => test_base.py} | 0 tests/{test_gui_events.py => test_events.py} | 0 tests/{test_gui_glfw.py => test_glfw.py} | 0 tests/{test_gui_offscreen.py => test_offscreen.py} | 0 tests/{test_gui_scheduling.py => test_scheduling.py} | 0 tests/{test_gui_utils.py => test_utils.py} | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename tests/{test_gui_base.py => test_base.py} (100%) rename tests/{test_gui_events.py => test_events.py} (100%) rename tests/{test_gui_glfw.py => test_glfw.py} (100%) rename tests/{test_gui_offscreen.py => test_offscreen.py} (100%) rename tests/{test_gui_scheduling.py => test_scheduling.py} (100%) rename tests/{test_gui_utils.py => test_utils.py} (100%) diff --git a/tests/test_gui_base.py b/tests/test_base.py similarity index 100% rename from tests/test_gui_base.py rename to tests/test_base.py diff --git a/tests/test_gui_events.py b/tests/test_events.py similarity index 100% rename from tests/test_gui_events.py rename to tests/test_events.py diff --git a/tests/test_gui_glfw.py b/tests/test_glfw.py similarity index 100% rename from tests/test_gui_glfw.py rename to tests/test_glfw.py diff --git a/tests/test_gui_offscreen.py b/tests/test_offscreen.py similarity index 100% rename from tests/test_gui_offscreen.py rename to tests/test_offscreen.py diff --git a/tests/test_gui_scheduling.py b/tests/test_scheduling.py similarity index 100% rename from tests/test_gui_scheduling.py rename to tests/test_scheduling.py diff --git a/tests/test_gui_utils.py b/tests/test_utils.py similarity index 100% rename from tests/test_gui_utils.py rename to tests/test_utils.py From d740f385d238eccd9883f5d38aba1996695d5a58 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 6 Nov 2024 10:18:33 +0100 Subject: [PATCH 4/8] Rename WgpuLoop and WgpuTimer --- README.md | 2 +- docs/api.rst | 8 ++++---- rendercanvas/__init__.py | 6 +++--- rendercanvas/_loop.py | 10 +++++----- rendercanvas/asyncio.py | 8 ++++---- rendercanvas/base.py | 4 ++-- rendercanvas/glfw.py | 6 +++--- rendercanvas/jupyter.py | 6 +++--- rendercanvas/offscreen.py | 10 +++++----- rendercanvas/qt.py | 10 +++++----- rendercanvas/wx.py | 10 +++++----- tests/test_scheduling.py | 8 ++++---- 12 files changed, 44 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 3deb784..7cea9af 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Also see the [online documentation](https://rendercanvas.readthedocs.io) and the ```py # Select either the glfw, qt or jupyter backend -from rendercanvas.auto import WgpuCanvas, loop +from rendercanvas.auto import RenderCanvas, loop # Visualizations can be embedded as a widget in a Qt application. # Supported qt libs are PySide6, PyQt6, PySide2 or PyQt5. diff --git a/docs/api.rst b/docs/api.rst index 1929774..b62fbed 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1,14 +1,14 @@ rendercanvas base classes ========================= -.. autoclass:: rendercanvas.base.WgpuCanvasInterface +.. autoclass:: rendercanvas.base.RenderCanvasInterface :members: -.. autoclass:: rendercanvas.base.WgpuCanvasBase +.. autoclass:: rendercanvas.base.BaseRenderCanvas :members: -.. .. autoclass:: rendercanvas.base.WgpuLoop +.. .. autoclass:: rendercanvas.base.BaseLoop .. :members: -.. .. autoclass:: rendercanvas.base.WgpuTimer +.. .. autoclass:: rendercanvas.base.BaseTimer .. :members: diff --git a/rendercanvas/__init__.py b/rendercanvas/__init__.py index c46362b..789d076 100644 --- a/rendercanvas/__init__.py +++ b/rendercanvas/__init__.py @@ -7,12 +7,12 @@ from ._version import __version__, version_info from . import _gui_utils from ._events import WgpuEventType -from .base import RenderCanvasInterface, BaseRenderCanvas, WgpuLoop, WgpuTimer +from .base import RenderCanvasInterface, BaseRenderCanvas, BaseLoop, BaseTimer __all__ = [ "RenderCanvasInterface", "BaseRenderCanvas", "WgpuEventType", - "WgpuLoop", - "WgpuTimer", + "BaseLoop", + "BaseTimer", ] diff --git a/rendercanvas/_loop.py b/rendercanvas/_loop.py index adffa36..f32fe59 100644 --- a/rendercanvas/_loop.py +++ b/rendercanvas/_loop.py @@ -12,7 +12,7 @@ # That would e.g. allow using glfw with qt together. Probably a too weird use-case for the added complexity. -class WgpuTimer: +class BaseTimer: """Base class for a timer objects.""" _running_timers = set() @@ -43,7 +43,7 @@ def start(self, interval): self._init() if self.is_running: self._stop() - WgpuTimer._running_timers.add(self) + BaseTimer._running_timers.add(self) self._interval = max(0.0, float(interval)) self._expect_tick_at = time.perf_counter() + self._interval self._start() @@ -55,7 +55,7 @@ def stop(self): callback is *not* called. If the timer is currently not running, this method does nothing. """ - WgpuTimer._running_timers.discard(self) + BaseTimer._running_timers.discard(self) self._expect_tick_at = None self._stop() @@ -63,7 +63,7 @@ def _tick(self): """The implementations must call this method.""" # Stop or restart if self._one_shot: - WgpuTimer._running_timers.discard(self) + BaseTimer._running_timers.discard(self) self._expect_tick_at = None else: self._expect_tick_at = time.perf_counter() + self._interval @@ -120,7 +120,7 @@ def _stop(self): raise NotImplementedError() -class WgpuLoop: +class BaseLoop: """Base class for event-loop objects.""" _TimerClass = None # subclases must set this diff --git a/rendercanvas/asyncio.py b/rendercanvas/asyncio.py index 808040f..db9441b 100644 --- a/rendercanvas/asyncio.py +++ b/rendercanvas/asyncio.py @@ -6,10 +6,10 @@ import asyncio -from .base import WgpuLoop, WgpuTimer +from .base import BaseLoop, BaseTimer -class AsyncioWgpuTimer(WgpuTimer): +class AsyncioTimer(BaseTimer): """Wgpu timer based on asyncio.""" _handle = None @@ -30,8 +30,8 @@ def _stop(self): self._handle = None -class AsyncioWgpuLoop(WgpuLoop): - _TimerClass = AsyncioWgpuTimer +class AsyncioLoop(BaseLoop): + _TimerClass = AsyncioTimer _the_loop = None _is_interactive = False diff --git a/rendercanvas/base.py b/rendercanvas/base.py index bc27e41..461a536 100644 --- a/rendercanvas/base.py +++ b/rendercanvas/base.py @@ -1,7 +1,7 @@ import sys from ._events import EventEmitter, WgpuEventType # noqa: F401 -from ._loop import Scheduler, WgpuLoop, WgpuTimer # noqa: F401 +from ._loop import Scheduler, BaseLoop, BaseTimer # noqa: F401 from ._gui_utils import log_exception @@ -294,7 +294,7 @@ def _draw_frame_and_present(self): def _get_loop(self): """For the subclass to implement: - Must return the global loop instance (WgpuLoop) for the canvas subclass, + Must return the global loop instance (a BaseLoop subclass) for the canvas subclass, or None for a canvas without scheduled draws. """ return None diff --git a/rendercanvas/glfw.py b/rendercanvas/glfw.py index 442418f..d61bed9 100644 --- a/rendercanvas/glfw.py +++ b/rendercanvas/glfw.py @@ -15,7 +15,7 @@ import glfw from .base import BaseRenderCanvas -from .asyncio import AsyncioWgpuLoop +from .asyncio import AsyncioLoop from ._gui_utils import SYSTEM_IS_WAYLAND, weakbind, logger @@ -526,7 +526,7 @@ def present_image(self, image, **kwargs): RenderCanvas = GlfwRenderCanvas -class GlfwAsyncioWgpuLoop(AsyncioWgpuLoop): +class GlfwAsyncioLoop(AsyncioLoop): def __init__(self): super().__init__() self.all_glfw_canvases = weakref.WeakSet() @@ -551,7 +551,7 @@ def _run(self): poll_glfw_briefly() -loop = GlfwAsyncioWgpuLoop() +loop = GlfwAsyncioLoop() run = loop.run # backwards compat diff --git a/rendercanvas/jupyter.py b/rendercanvas/jupyter.py index de58d7f..400a71a 100644 --- a/rendercanvas/jupyter.py +++ b/rendercanvas/jupyter.py @@ -7,7 +7,7 @@ import weakref from .base import BaseRenderCanvas -from .asyncio import AsyncioWgpuLoop +from .asyncio import AsyncioLoop import numpy as np from jupyter_rfb import RemoteFrameBuffer @@ -126,7 +126,7 @@ def present_image(self, image, **kwargs): RenderCanvas = JupyterRenderCanvas -class JupyterAsyncioWgpuLoop(AsyncioWgpuLoop): +class JupyterAsyncioLoop(AsyncioLoop): def __init__(self): super().__init__() self._pending_jupyter_canvases = [] @@ -144,4 +144,4 @@ def run(self): display(w) -loop = JupyterAsyncioWgpuLoop() +loop = JupyterAsyncioLoop() diff --git a/rendercanvas/offscreen.py b/rendercanvas/offscreen.py index 3da5d1c..a99683d 100644 --- a/rendercanvas/offscreen.py +++ b/rendercanvas/offscreen.py @@ -1,4 +1,4 @@ -from .base import BaseRenderCanvas, WgpuLoop, WgpuTimer +from .base import BaseRenderCanvas, BaseLoop, BaseTimer class WgpuManualOffscreenCanvas(BaseRenderCanvas): @@ -72,7 +72,7 @@ def draw(self): RenderCanvas = WgpuManualOffscreenCanvas -class StubWgpuTimer(WgpuTimer): +class StubTimer(BaseTimer): def _start(self): pass @@ -80,7 +80,7 @@ def _stop(self): pass -class StubLoop(WgpuLoop): +class StubLoop(BaseLoop): # If we consider the use-cases for using this offscreen canvas: # # * Using rendercanvas.auto in test-mode: in this case run() should not hang, @@ -94,11 +94,11 @@ class StubLoop(WgpuLoop): # In summary, we provide a call_later() and run() that behave pretty # well for the first case. - _TimerClass = StubWgpuTimer # subclases must set this + _TimerClass = StubTimer # subclases must set this def _process_timers(self): # Running this loop processes any timers - for timer in list(WgpuTimer._running_timers): + for timer in list(BaseTimer._running_timers): if timer.time_left <= 0: timer._tick() diff --git a/rendercanvas/qt.py b/rendercanvas/qt.py index e2d49f7..b01c1b5 100644 --- a/rendercanvas/qt.py +++ b/rendercanvas/qt.py @@ -7,7 +7,7 @@ import ctypes import importlib -from .base import BaseRenderCanvas, WgpuLoop, WgpuTimer, pop_kwargs_for_base_canvas +from .base import BaseRenderCanvas, BaseLoop, BaseTimer, pop_kwargs_for_base_canvas from ._gui_utils import ( logger, SYSTEM_IS_WAYLAND, @@ -548,7 +548,7 @@ def present_image(self, image, **kwargs): RenderCanvas = QRenderCanvas -class QtWgpuTimer(WgpuTimer): +class QtTimer(BaseTimer): """Wgpu timer basef on Qt.""" def _init(self): @@ -564,8 +564,8 @@ def _stop(self): self._qt_timer.stop() -class QtWgpuLoop(WgpuLoop): - _TimerClass = QtWgpuTimer +class QtLoop(BaseLoop): + _TimerClass = QtTimer def init_qt(self): _ = self._app @@ -607,5 +607,5 @@ def _wgpu_gui_poll(self): pass # we assume the Qt event loop is running. Calling processEvents() will cause recursive repaints. -loop = QtWgpuLoop() +loop = QtLoop() run = loop.run # backwards compat diff --git a/rendercanvas/wx.py b/rendercanvas/wx.py index bc85e01..f8b755c 100644 --- a/rendercanvas/wx.py +++ b/rendercanvas/wx.py @@ -16,7 +16,7 @@ get_alt_x11_display, get_alt_wayland_display, ) -from .base import BaseRenderCanvas, WgpuLoop, WgpuTimer, pop_kwargs_for_base_canvas +from .base import BaseRenderCanvas, BaseLoop, BaseTimer, pop_kwargs_for_base_canvas BUTTON_MAP = { @@ -527,7 +527,7 @@ def Notify(self, *args): # noqa: N802 pass # wrapped C/C++ object of type WxWgpuWindow has been deleted -class WxWgpuTimer(WgpuTimer): +class WxTimer(BaseTimer): def _init(self): self._wx_timer = TimerWithCallback(self._tick) @@ -538,8 +538,8 @@ def _stop(self): self._wx_timer.Stop() -class WxWgpuLoop(WgpuLoop): - _TimerClass = WxWgpuTimer +class WxLoop(BaseLoop): + _TimerClass = WxTimer _the_app = None _frame_to_keep_loop_alive = None @@ -577,5 +577,5 @@ def process_wx_events(self): wx.GUIEventLoop.SetActive(old) -loop = WxWgpuLoop() +loop = WxLoop() run = loop.run # backwards compat diff --git a/tests/test_scheduling.py b/tests/test_scheduling.py index 9a6174c..347a7c5 100644 --- a/tests/test_scheduling.py +++ b/tests/test_scheduling.py @@ -6,10 +6,10 @@ import time from testutils import run_tests -from rendercanvas import BaseRenderCanvas, WgpuLoop, WgpuTimer +from rendercanvas import BaseRenderCanvas, BaseLoop, BaseTimer -class MyTimer(WgpuTimer): +class MyTimer(BaseTimer): def _start(self): pass @@ -17,7 +17,7 @@ def _stop(self): pass -class MyLoop(WgpuLoop): +class MyLoop(BaseLoop): _TimerClass = MyTimer def __init__(self): @@ -25,7 +25,7 @@ def __init__(self): self.__stopped = False def process_timers(self): - for timer in list(WgpuTimer._running_timers): + for timer in list(BaseTimer._running_timers): if timer.time_left <= 0: timer._tick() From 4cd128522394a9f80647450d21d44044582371db Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 6 Nov 2024 10:24:07 +0100 Subject: [PATCH 5/8] Rename RenderWidget --- README.md | 2 +- docs/gui.rst | 4 ++-- examples/qt_app.py | 4 ++-- examples/qt_app_asyncio.py | 4 ++-- examples/wx_app.py | 6 +++--- rendercanvas/qt.py | 6 +++--- rendercanvas/wx.py | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7cea9af..24e0773 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ from rendercanvas.auto import RenderCanvas, loop # Visualizations can be embedded as a widget in a Qt application. # Supported qt libs are PySide6, PyQt6, PySide2 or PyQt5. -from rendercanvas.pyside6 import QWgpuWidget +from rendercanvas.pyside6 import QRenderWidget # Now specify what the canvas should do on a draw diff --git a/docs/gui.rst b/docs/gui.rst index 8b305ec..be9b4b5 100644 --- a/docs/gui.rst +++ b/docs/gui.rst @@ -78,7 +78,7 @@ Support for Qt There is support for PyQt5, PyQt6, PySide2 and PySide6. The rendercanvas library detects what library you are using by looking what module has been imported. For a toplevel widget, the ``rendercanvas.qt.RenderCanvas`` class can be imported. If you want to -embed the canvas as a subwidget, use ``rendercanvas.qt.WgpuWidget`` instead. +embed the canvas as a subwidget, use ``rendercanvas.qt.QRenderWidget`` instead. Also see the `Qt triangle example `_ and `Qt triangle embed example `_. @@ -106,7 +106,7 @@ Support for wx There is support for embedding a wgpu visualization in wxPython. For a toplevel widget, the ``gui.wx.RenderCanvas`` class can be imported. If you want to -embed the canvas as a subwidget, use ``gui.wx.WgpuWidget`` instead. +embed the canvas as a subwidget, use ``gui.wx.RenderWidget`` instead. Also see the `wx triangle example `_ and `wx triangle embed example `_. diff --git a/examples/qt_app.py b/examples/qt_app.py index 5e531af..a109a48 100644 --- a/examples/qt_app.py +++ b/examples/qt_app.py @@ -18,7 +18,7 @@ except ModuleNotFoundError: pass -from rendercanvas.qt import QWgpuWidget +from rendercanvas.qt import QRenderWidget from rendercanvas.utils.cube import setup_drawing_sync @@ -31,7 +31,7 @@ def __init__(self): splitter = QtWidgets.QSplitter() self.button = QtWidgets.QPushButton("Hello world", self) - self.canvas = QWgpuWidget(splitter) + self.canvas = QRenderWidget(splitter) self.output = QtWidgets.QTextEdit(splitter) self.button.clicked.connect(self.whenButtonClicked) diff --git a/examples/qt_app_asyncio.py b/examples/qt_app_asyncio.py index 059f800..dd8386f 100644 --- a/examples/qt_app_asyncio.py +++ b/examples/qt_app_asyncio.py @@ -17,7 +17,7 @@ import asyncio from PySide6 import QtWidgets, QtAsyncio -from rendercanvas.qt import QWgpuWidget +from rendercanvas.qt import QRenderWidget from rendercanvas.utils.cube import setup_drawing_sync @@ -49,7 +49,7 @@ def __init__(self): # todo: use update_mode = 'continuous' when that feature has arrived self.button = QtWidgets.QPushButton("Hello world", self) - self.canvas = QWgpuWidget(splitter) + self.canvas = QRenderWidget(splitter) self.output = QtWidgets.QTextEdit(splitter) # self.button.clicked.connect(self.whenButtonClicked) # see above :( diff --git a/examples/wx_app.py b/examples/wx_app.py index a3232f9..8916de3 100644 --- a/examples/wx_app.py +++ b/examples/wx_app.py @@ -3,7 +3,7 @@ """ import wx -from rendercanvas.wx import WgpuWidget +from rendercanvas.wx import RenderWidget from rendercanvas.utils.cube import setup_drawing_sync @@ -16,8 +16,8 @@ def __init__(self): splitter = wx.SplitterWindow(self) self.button = wx.Button(self, -1, "Hello world") - self.canvas1 = WgpuWidget(splitter) - self.canvas2 = WgpuWidget(splitter) + self.canvas1 = RenderWidget(splitter) + self.canvas2 = RenderWidget(splitter) splitter.SplitVertically(self.canvas1, self.canvas2) splitter.SetSashGravity(0.5) diff --git a/rendercanvas/qt.py b/rendercanvas/qt.py index b01c1b5..1e686ed 100644 --- a/rendercanvas/qt.py +++ b/rendercanvas/qt.py @@ -139,7 +139,7 @@ def enable_hidpi(): ) -class QWgpuWidget(BaseRenderCanvas, QtWidgets.QWidget): +class QRenderWidget(BaseRenderCanvas, QtWidgets.QWidget): """A QWidget representing a wgpu canvas that can be embedded in a Qt application.""" def __init__(self, *args, present_method=None, **kwargs): @@ -471,7 +471,7 @@ def __init__(self, *, size=None, title=None, **kwargs): self.setAttribute(WA_DeleteOnClose, True) self.setMouseTracking(True) - self._subwidget = QWgpuWidget(self, **sub_kwargs) + self._subwidget = QRenderWidget(self, **sub_kwargs) self._events = self._subwidget._events # Note: At some point we called `self._subwidget.winId()` here. For some @@ -544,7 +544,7 @@ def present_image(self, image, **kwargs): # Make available under a name that is the same for all gui backends -WgpuWidget = QWgpuWidget +RenderWidget = QRenderWidget RenderCanvas = QRenderCanvas diff --git a/rendercanvas/wx.py b/rendercanvas/wx.py index f8b755c..31413dd 100644 --- a/rendercanvas/wx.py +++ b/rendercanvas/wx.py @@ -120,7 +120,7 @@ def enable_hidpi(): ) -class WxWgpuWindow(BaseRenderCanvas, wx.Window): +class WxRenderWidget(BaseRenderCanvas, wx.Window): """A wx Window representing a wgpu canvas that can be embedded in a wx application.""" def __init__(self, *args, present_method=None, **kwargs): @@ -511,7 +511,7 @@ def present_image(self, image, **kwargs): # Make available under a name that is the same for all gui backends -WgpuWidget = WxWgpuWindow +RenderWidget = WxRenderWidget RenderCanvas = WxRenderCanvas From f817810456372d6ec34b061db94db68ede68edaf Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 6 Nov 2024 10:26:56 +0100 Subject: [PATCH 6/8] Rename WgpuEventType -> EventType --- docs/gui.rst | 2 +- rendercanvas/__init__.py | 4 ++-- rendercanvas/_events.py | 8 ++++---- rendercanvas/base.py | 4 ++-- tests/test_events.py | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/gui.rst b/docs/gui.rst index be9b4b5..1513274 100644 --- a/docs/gui.rst +++ b/docs/gui.rst @@ -26,7 +26,7 @@ Events To implement interaction with a ``RenderCanvas``, use the :func:`BaseRenderCanvas.add_event_handler()` method. Events come in the following flavours: -.. autoclass:: WgpuEventType +.. autoclass:: EventType :members: diff --git a/rendercanvas/__init__.py b/rendercanvas/__init__.py index 789d076..059d713 100644 --- a/rendercanvas/__init__.py +++ b/rendercanvas/__init__.py @@ -6,13 +6,13 @@ from ._version import __version__, version_info from . import _gui_utils -from ._events import WgpuEventType +from ._events import EventType from .base import RenderCanvasInterface, BaseRenderCanvas, BaseLoop, BaseTimer __all__ = [ "RenderCanvasInterface", "BaseRenderCanvas", - "WgpuEventType", + "EventType", "BaseLoop", "BaseTimer", ] diff --git a/rendercanvas/_events.py b/rendercanvas/_events.py index 42adbfa..83bfa06 100644 --- a/rendercanvas/_events.py +++ b/rendercanvas/_events.py @@ -5,8 +5,8 @@ from ._coreutils import BaseEnum -class WgpuEventType(BaseEnum): - """The WgpuEventType enum specifies the possible events for a RenderCanvas. +class EventType(BaseEnum): + """The EventType enum specifies the possible events for a RenderCanvas. This includes the events from the jupyter_rfb event spec (see https://jupyter-rfb.readthedocs.io/en/stable/events.html) plus some @@ -116,7 +116,7 @@ def my_handler(event): for type in types: if not isinstance(type, str): raise TypeError(f"Event types must be str, but got {type}") - if not (type == "*" or type in WgpuEventType): + if not (type == "*" or type in EventType): raise ValueError(f"Adding handler with invalid event_type: '{type}'") def decorator(_callback): @@ -153,7 +153,7 @@ def submit(self, event): Events are emitted later by the scheduler. """ event_type = event["event_type"] - if event_type not in WgpuEventType: + if event_type not in EventType: raise ValueError(f"Submitting with invalid event_type: '{event_type}'") if event_type == "close": self._closed = True diff --git a/rendercanvas/base.py b/rendercanvas/base.py index 461a536..3b1fc65 100644 --- a/rendercanvas/base.py +++ b/rendercanvas/base.py @@ -1,6 +1,6 @@ import sys -from ._events import EventEmitter, WgpuEventType # noqa: F401 +from ._events import EventEmitter, EventType # noqa: F401 from ._loop import Scheduler, BaseLoop, BaseTimer # noqa: F401 from ._gui_utils import log_exception @@ -90,7 +90,7 @@ class BaseRenderCanvas(RenderCanvasInterface): code that is portable accross multiple GUI libraries and canvas targets. Arguments: - update_mode (WgpuEventType): The mode for scheduling draws and events. Default 'ondemand'. + update_mode (EventType): The mode for scheduling draws and events. Default 'ondemand'. min_fps (float): A minimal frames-per-second to use when the ``update_mode`` is 'ondemand'. The default is 1: even without draws requested, it still draws every second. max_fps (float): A maximal frames-per-second to use when the ``update_mode`` is 'ondemand' or 'continuous'. diff --git a/tests/test_events.py b/tests/test_events.py index 461f991..f8e7788 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -4,7 +4,7 @@ import time -from rendercanvas._events import EventEmitter, WgpuEventType +from rendercanvas._events import EventEmitter, EventType from testutils import run_tests import pytest @@ -16,7 +16,7 @@ def handler(event): pass # All these are valid - valid_types = list(WgpuEventType) + valid_types = list(EventType) ee.add_handler(handler, *valid_types) # This is not From 2ea25984ac72ec0cb4e4b3869d16db4df8e73a09 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 6 Nov 2024 10:49:36 +0100 Subject: [PATCH 7/8] More renames, removing inappropriate refs to wgpu --- docs/conf.py | 2 +- docs/start.rst | 2 +- examples/events.py | 2 +- rendercanvas/_events.py | 4 ++-- rendercanvas/_loop.py | 8 ++++---- rendercanvas/asyncio.py | 2 +- rendercanvas/auto.py | 14 +++++++------- rendercanvas/base.py | 4 ++-- rendercanvas/glfw.py | 10 +++++----- rendercanvas/jupyter.py | 4 ++-- rendercanvas/offscreen.py | 4 ++-- rendercanvas/qt.py | 16 ++++++++-------- rendercanvas/wx.py | 12 ++++++------ tests/test_offscreen.py | 6 +++--- 14 files changed, 45 insertions(+), 45 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index aad2807..f751318 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,7 +47,7 @@ intersphinx_mapping = { "python": ("https://docs.python.org/3", None), "numpy": ("https://numpy.org/doc/stable", None), - "wgpu": ("https://wgpu-py.readthedocs.io/en/latest", None), + "wgpu": ("https://wgpu-py.readthedocs.io/en/stable", None), } # Add any paths that contain templates here, relative to this directory. diff --git a/docs/start.rst b/docs/start.rst index 801798e..abca9ad 100644 --- a/docs/start.rst +++ b/docs/start.rst @@ -25,6 +25,6 @@ GUI libraries Multiple GUI backends are supported, see :doc:`the GUI API ` for details: * `glfw `_: a lightweight GUI for the desktop -* `jupyter_rfb `_: only needed if you plan on using wgpu in Jupyter +* `jupyter_rfb `_: only needed if you plan on using Jupyter * qt (PySide6, PyQt6, PySide2, PyQt5) * wx diff --git a/examples/events.py b/examples/events.py index a0a9476..61f80b2 100644 --- a/examples/events.py +++ b/examples/events.py @@ -5,7 +5,7 @@ from rendercanvas.auto import RenderCanvas, run -canvas = RenderCanvas(size=(640, 480), title="wgpu events") +canvas = RenderCanvas(size=(640, 480), title="RenderCanvas events") @canvas.add_event_handler("*") diff --git a/rendercanvas/_events.py b/rendercanvas/_events.py index 83bfa06..6355bf3 100644 --- a/rendercanvas/_events.py +++ b/rendercanvas/_events.py @@ -10,7 +10,7 @@ class EventType(BaseEnum): This includes the events from the jupyter_rfb event spec (see https://jupyter-rfb.readthedocs.io/en/stable/events.html) plus some - wgpu-specific events. + rendercanvas-specific events. """ # Jupter_rfb spec @@ -207,7 +207,7 @@ def emit(self, event): with log_exception(f"Error during handling {event_type} event"): callback(event) - def _wgpu_close(self): + def _rc_close(self): """Wrap up when the scheduler detects the canvas is closed/dead.""" # This is a little feature because detecting a widget from closing can be tricky. if not self._closed: diff --git a/rendercanvas/_loop.py b/rendercanvas/_loop.py index f32fe59..c7a602a 100644 --- a/rendercanvas/_loop.py +++ b/rendercanvas/_loop.py @@ -135,7 +135,7 @@ def __init__(self): # loop usually stops when the last window is closed, so the close event may # not be fired. # * Keep the GUI going even when the canvas loop is on pause e.g. because its - # minimized (applies to backends that implement _wgpu_gui_poll). + # minimized (applies to backends that implement _rc_gui_poll). self._gui_timer = self._TimerClass(self, self._tick, one_shot=False) def _register_scheduler(self, scheduler): @@ -145,7 +145,7 @@ def _register_scheduler(self, scheduler): def _tick(self): # Keep the GUI alive on every tick - self._wgpu_gui_poll() + self._rc_gui_poll() # Check all schedulers schedulers_to_close = [] @@ -235,7 +235,7 @@ def _call_soon(self, callback, *args): """ self.call_later(0, callback, *args) - def _wgpu_gui_poll(self): + def _rc_gui_poll(self): """For the subclass to implement: Some event loops (e.g. asyncio) are just that and dont have a GUI to update. @@ -343,7 +343,7 @@ def _get_canvas(self): canvas = self._canvas_ref() if canvas is None or canvas.is_closed(): # Pretty nice, we can send a close event, even if the canvas no longer exists - self._events._wgpu_close() + self._events._rc_close() return None else: return canvas diff --git a/rendercanvas/asyncio.py b/rendercanvas/asyncio.py index db9441b..76398e0 100644 --- a/rendercanvas/asyncio.py +++ b/rendercanvas/asyncio.py @@ -10,7 +10,7 @@ class AsyncioTimer(BaseTimer): - """Wgpu timer based on asyncio.""" + """Timer based on asyncio.""" _handle = None diff --git a/rendercanvas/auto.py b/rendercanvas/auto.py index 71e00ab..acd00df 100644 --- a/rendercanvas/auto.py +++ b/rendercanvas/auto.py @@ -14,7 +14,7 @@ # Note that wx is not in here, because it does not (yet) fully implement base.BaseRenderCanvas -WGPU_GUI_BACKEND_NAMES = ["glfw", "qt", "jupyter", "offscreen"] +BACKEND_NAMES = ["glfw", "qt", "jupyter", "offscreen"] def _load_backend(backend_name): @@ -30,7 +30,7 @@ def _load_backend(backend_name): elif backend_name == "offscreen": from . import offscreen as module else: # no-cover - raise ImportError("Unknown wgpu gui backend: '{backend_name}'") + raise ImportError("Unknown rendercanvas backend: '{backend_name}'") return module @@ -53,7 +53,7 @@ def select_backend(): # Always report failed backends, because we only try them when it looks like we can. if failed_backends: - msg = "WGPU could not load some backends:" + msg = "rendercanvas could not load some backends:" for key, val in failed_backends.items(): msg += f"\n{key}: {val}" logger.warning(msg) @@ -61,10 +61,10 @@ def select_backend(): # Return or raise if module is not None: log = logger.warning if failed_backends else logger.info - log(f"WGPU selected {backend_name} gui because {reason}.") + log(f"Rendercanvas selected {backend_name} backend because {reason}.") return module else: - msg = "WGPU Could not load any of the supported GUI backends." + msg = "Rendercanvas could not load any of the supported backends." if "jupyter" in failed_backends: msg += "\n You may need to ``pip install -U jupyter_rfb``." else: @@ -94,9 +94,9 @@ def backends_by_env_vars(): # Env var to force a backend for general use backend_name = os.getenv("WGPU_GUI_BACKEND", "").lower().strip() or None if backend_name: - if backend_name not in WGPU_GUI_BACKEND_NAMES: + if backend_name not in BACKEND_NAMES: logger.warning( - f"Ignoring invalid WGPU_GUI_BACKEND '{backend_name}', must be one of {WGPU_GUI_BACKEND_NAMES}" + f"Ignoring invalid WGPU_GUI_BACKEND '{backend_name}', must be one of {BACKEND_NAMES}" ) backend_name = None if backend_name: diff --git a/rendercanvas/base.py b/rendercanvas/base.py index 3b1fc65..78a3295 100644 --- a/rendercanvas/base.py +++ b/rendercanvas/base.py @@ -173,7 +173,7 @@ def _process_events(self): # Get events from the GUI into our event mechanism. loop = self._get_loop() if loop: - loop._wgpu_gui_poll() + loop._rc_gui_poll() # Flush our events, so downstream code can update stuff. # Maybe that downstream code request a new draw. @@ -245,7 +245,7 @@ def force_draw(self): def _draw_frame_and_present(self): """Draw the frame and present the result. - Errors are logged to the "wgpu" logger. Should be called by the + Errors are logged to the "rendercanvas" logger. Should be called by the subclass at its draw event. """ diff --git a/rendercanvas/glfw.py b/rendercanvas/glfw.py index d61bed9..5dcad5e 100644 --- a/rendercanvas/glfw.py +++ b/rendercanvas/glfw.py @@ -22,13 +22,13 @@ # Make sure that glfw is new enough glfw_version_info = tuple(int(i) for i in glfw.__version__.split(".")[:2]) if glfw_version_info < (1, 9): - raise ImportError("wgpu-py requires glfw 1.9 or higher.") + raise ImportError("rendercanvas requires glfw 1.9 or higher.") # Do checks to prevent pitfalls on hybrid Xorg/Wayland systems is_wayland = False if sys.platform.startswith("linux") and SYSTEM_IS_WAYLAND: if not hasattr(glfw, "get_x11_window"): - # Probably glfw was imported before we wgpu was, so we missed our chance + # Probably glfw was imported before this module, so we missed our chance # to set the env var to make glfw use x11. is_wayland = True logger.warning("Using GLFW with Wayland, which is experimental.") @@ -142,7 +142,7 @@ def get_physical_size(window): class GlfwRenderCanvas(BaseRenderCanvas): - """A glfw window providing a wgpu canvas.""" + """A glfw window providing a render canvas.""" # See https://www.glfw.org/docs/latest/group__window.html @@ -201,7 +201,7 @@ def __init__(self, *, size=None, title=None, **kwargs): self.set_logical_size(*size) self.set_title(title) - # Callbacks to provide a minimal working canvas for wgpu + # Callbacks to provide a minimal working canvas def _on_pixelratio_change(self, *args): if self._changing_pixel_ratio: @@ -539,7 +539,7 @@ def init_glfw(self): self._glfw_initialized = True atexit.register(glfw.terminate) - def _wgpu_gui_poll(self): + def _rc_gui_poll(self): glfw.post_empty_event() # Awake the event loop, if it's in wait-mode glfw.poll_events() if self.stop_if_no_more_canvases and not tuple(self.all_glfw_canvases): diff --git a/rendercanvas/jupyter.py b/rendercanvas/jupyter.py index 400a71a..585e686 100644 --- a/rendercanvas/jupyter.py +++ b/rendercanvas/jupyter.py @@ -15,7 +15,7 @@ class JupyterRenderCanvas(BaseRenderCanvas, RemoteFrameBuffer): - """An ipywidgets widget providing a wgpu canvas. Needs the jupyter_rfb library.""" + """An ipywidgets widget providing a render canvas. Needs the jupyter_rfb library.""" def __init__(self, *, size=None, title=None, **kwargs): super().__init__(**kwargs) @@ -131,7 +131,7 @@ def __init__(self): super().__init__() self._pending_jupyter_canvases = [] - def _wgpu_gui_poll(self): + def _rc_gui_poll(self): pass # Jupyter is running in a separate process :) def run(self): diff --git a/rendercanvas/offscreen.py b/rendercanvas/offscreen.py index a99683d..522faf7 100644 --- a/rendercanvas/offscreen.py +++ b/rendercanvas/offscreen.py @@ -1,7 +1,7 @@ from .base import BaseRenderCanvas, BaseLoop, BaseTimer -class WgpuManualOffscreenCanvas(BaseRenderCanvas): +class ManualOffscreenRenderCanvas(BaseRenderCanvas): """An offscreen canvas intended for manual use. Call the ``.draw()`` method to perform a draw and get the result. @@ -69,7 +69,7 @@ def draw(self): return self._last_image -RenderCanvas = WgpuManualOffscreenCanvas +RenderCanvas = ManualOffscreenRenderCanvas class StubTimer(BaseTimer): diff --git a/rendercanvas/qt.py b/rendercanvas/qt.py index 1e686ed..1dfbf9a 100644 --- a/rendercanvas/qt.py +++ b/rendercanvas/qt.py @@ -128,10 +128,10 @@ def enable_hidpi(): pass # fail on older Qt's -# If you import this module, you want to use wgpu in a way that does not suck +# If you import this module, you want to render in a way that does not suck # on high-res monitors. So we apply the minimal configuration to make this so. # Most apps probably should also set AA_UseHighDpiPixmaps, but it's not -# needed for wgpu, so not our responsibility (some users may NOT want it set). +# needed, so not our responsibility (some users may NOT want it set). enable_hidpi() _show_image_method_warning = ( @@ -140,7 +140,7 @@ def enable_hidpi(): class QRenderWidget(BaseRenderCanvas, QtWidgets.QWidget): - """A QWidget representing a wgpu canvas that can be embedded in a Qt application.""" + """A QWidget representing a render canvas that can be embedded in a Qt application.""" def __init__(self, *args, present_method=None, **kwargs): super().__init__(*args, **kwargs) @@ -182,7 +182,7 @@ def paintEngine(self): # noqa: N802 - this is a Qt method def paintEvent(self, event): # noqa: N802 - this is a Qt method self._draw_frame_and_present() - # Methods that we add from wgpu (snake_case) + # Methods that we add for BaseRenderCanvas (snake_case) def _request_draw(self): # Ask Qt to do a paint event @@ -447,7 +447,7 @@ def present_image(self, image_data, **kwargs): class QRenderCanvas(BaseRenderCanvas, QtWidgets.QWidget): - """A toplevel Qt widget providing a wgpu canvas.""" + """A toplevel Qt widget providing a render canvas.""" # Most of this is proxying stuff to the inner widget. # We cannot use a toplevel widget directly, otherwise the window @@ -494,7 +494,7 @@ def closeEvent(self, event): # noqa: N802 self._subwidget._is_closed = True self.submit_event({"event_type": "close"}) - # Methods that we add from wgpu (snake_case) + # Methods that we add from BaseRenderCanvas (snake_case) def _request_draw(self): self._subwidget._request_draw() @@ -549,7 +549,7 @@ def present_image(self, image, **kwargs): class QtTimer(BaseTimer): - """Wgpu timer basef on Qt.""" + """Timer basef on Qt.""" def _init(self): self._qt_timer = QtCore.QTimer() @@ -603,7 +603,7 @@ def _stop(self): if not already_had_app_on_import: self._app.quit() - def _wgpu_gui_poll(self): + def _rc_gui_poll(self): pass # we assume the Qt event loop is running. Calling processEvents() will cause recursive repaints. diff --git a/rendercanvas/wx.py b/rendercanvas/wx.py index 31413dd..8fa5787 100644 --- a/rendercanvas/wx.py +++ b/rendercanvas/wx.py @@ -121,7 +121,7 @@ def enable_hidpi(): class WxRenderWidget(BaseRenderCanvas, wx.Window): - """A wx Window representing a wgpu canvas that can be embedded in a wx application.""" + """A wx Window representing a render canvas that can be embedded in a wx application.""" def __init__(self, *args, present_method=None, **kwargs): super().__init__(*args, **kwargs) @@ -310,7 +310,7 @@ def _on_mouse_events(self, event: wx.MouseEvent): def _on_mouse_move(self, event: wx.MouseEvent): self._mouse_event("pointer_move", event) - # Methods that we add from wgpu + # Methods that we add from BaseRenderCanvas def _get_surface_ids(self): if sys.platform.startswith("win") or sys.platform.startswith("darwin"): @@ -418,7 +418,7 @@ def present_image(self, image_data, **kwargs): class WxRenderCanvas(BaseRenderCanvas, wx.Frame): - """A toplevel wx Frame providing a wgpu canvas.""" + """A toplevel wx Frame providing a render canvas.""" # Most of this is proxying stuff to the inner widget. @@ -440,7 +440,7 @@ def __init__( if not size: size = 640, 480 - self._subwidget = WxWgpuWindow(parent=self, **sub_kwargs) + self._subwidget = WxRenderWidget(parent=self, **sub_kwargs) self._events = self._subwidget._events self.Bind(wx.EVT_CLOSE, lambda e: self.Destroy()) @@ -524,7 +524,7 @@ def Notify(self, *args): # noqa: N802 try: self._callback() except RuntimeError: - pass # wrapped C/C++ object of type WxWgpuWindow has been deleted + pass # wrapped C/C++ object of type WxRenderWidget has been deleted class WxTimer(BaseTimer): @@ -565,7 +565,7 @@ def _stop(self): self._frame_to_keep_loop_alive.Destroy() _frame_to_keep_loop_alive = None - def _wgpu_gui_poll(self): + def _rc_gui_poll(self): pass # We can assume the wx loop is running. def process_wx_events(self): diff --git a/tests/test_offscreen.py b/tests/test_offscreen.py index b01e6d7..75df1c8 100644 --- a/tests/test_offscreen.py +++ b/tests/test_offscreen.py @@ -10,7 +10,7 @@ def test_offscreen_selection_using_env_var(): - from rendercanvas.offscreen import WgpuManualOffscreenCanvas + from rendercanvas.offscreen import ManualOffscreenRenderCanvas ori = os.environ.get("WGPU_FORCE_OFFSCREEN", "") os.environ["WGPU_FORCE_OFFSCREEN"] = "1" @@ -23,12 +23,12 @@ def test_offscreen_selection_using_env_var(): for value in ["", "0", "false", "False", "wut"]: os.environ["WGPU_FORCE_OFFSCREEN"] = value module = select_backend() - assert module.RenderCanvas is not WgpuManualOffscreenCanvas + assert module.RenderCanvas is not ManualOffscreenRenderCanvas for value in ["1", "true", "True"]: os.environ["WGPU_FORCE_OFFSCREEN"] = value module = select_backend() - assert module.RenderCanvas is WgpuManualOffscreenCanvas + assert module.RenderCanvas is ManualOffscreenRenderCanvas finally: os.environ["WGPU_FORCE_OFFSCREEN"] = ori From df2e3dfb27d3f83b2682ecf0a6bdc5eb2d1401d4 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 6 Nov 2024 11:00:32 +0100 Subject: [PATCH 8/8] Remove some refs to 'gui' --- README.md | 2 +- docs/start.rst | 8 ++++---- examples/qt_app_asyncio.py | 2 +- rendercanvas/_gui_utils.py | 8 ++++---- rendercanvas/_loop.py | 2 +- rendercanvas/asyncio.py | 2 +- rendercanvas/auto.py | 10 +++++----- rendercanvas/base.py | 2 +- rendercanvas/glfw.py | 4 ++-- rendercanvas/jupyter.py | 2 +- tests/test_scheduling.py | 16 ++++++++-------- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 24e0773..3ed79b7 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ by producing rgba images. pip install rendercanvas ``` -To have at least one GUI backend, we recommend: +To have at least one backend, we recommend: ``` pip install rendercanvas glfw ``` diff --git a/docs/start.rst b/docs/start.rst index abca9ad..21c6551 100644 --- a/docs/start.rst +++ b/docs/start.rst @@ -19,12 +19,12 @@ Since most users will want to render something to screen, we recommend installin pip install rendercanvas glfw -GUI libraries -------------- +Backends +-------- -Multiple GUI backends are supported, see :doc:`the GUI API ` for details: +Multiple backends are supported, including multiple GUI libraries, see :doc:`the GUI API ` for details: -* `glfw `_: a lightweight GUI for the desktop +* `glfw `_: a lightweight canvas for the desktop * `jupyter_rfb `_: only needed if you plan on using Jupyter * qt (PySide6, PyQt6, PySide2, PyQt5) * wx diff --git a/examples/qt_app_asyncio.py b/examples/qt_app_asyncio.py index dd8386f..f7af902 100644 --- a/examples/qt_app_asyncio.py +++ b/examples/qt_app_asyncio.py @@ -1,7 +1,7 @@ """ An example demonstrating a qt app with a wgpu viz inside. -This is the same as the ``gui_qt_embed.py`` example, except this uses +This is the same as the ``qt_app.py`` example, except this uses the asyncio compatible mode that was introduced in Pyside 6.6. For more info see: diff --git a/rendercanvas/_gui_utils.py b/rendercanvas/_gui_utils.py index 601c917..f4cf5e5 100644 --- a/rendercanvas/_gui_utils.py +++ b/rendercanvas/_gui_utils.py @@ -1,4 +1,4 @@ -"""Private gui utilities.""" +"""Private utilities.""" import os import sys @@ -13,7 +13,7 @@ logger = logging.getLogger("rendercanvas") -# ===== GUI lib support +# ===== lib support QT_MODULE_NAMES = ["PySide6", "PyQt6", "PySide2", "PyQt5"] @@ -130,7 +130,7 @@ def proxy(*args, **kwargs): def get_alt_x11_display(): """Get (the pointer to) a process-global x11 display instance.""" - # Ideally we'd get the real display object used by the GUI toolkit. + # Ideally we'd get the real display object used by the backend. # But this is not always possible. In that case, using an alt display # object can be used. global _x11_display @@ -147,7 +147,7 @@ def get_alt_x11_display(): def get_alt_wayland_display(): """Get (the pointer to) a process-global Wayland display instance.""" - # Ideally we'd get the real display object used by the GUI toolkit. + # Ideally we'd get the real display object used by the backend. # This creates a global object, similar to what we do for X11. # Unfortunately, this segfaults, so it looks like the real display object # is needed? Leaving this here for reference. diff --git a/rendercanvas/_loop.py b/rendercanvas/_loop.py index c7a602a..1e17e41 100644 --- a/rendercanvas/_loop.py +++ b/rendercanvas/_loop.py @@ -332,7 +332,7 @@ def __init__(self, canvas, loop, *, mode="ondemand", min_fps=1, max_fps=30): assert loop is not None # Initialise the timer that runs our scheduling loop. - # Note that the gui may do a first draw earlier, starting the loop, and that's fine. + # Note that the backend may do a first draw earlier, starting the loop, and that's fine. self._last_tick_time = -0.1 self._timer = loop.call_later(0.1, self._tick) diff --git a/rendercanvas/asyncio.py b/rendercanvas/asyncio.py index 76398e0..161db1f 100644 --- a/rendercanvas/asyncio.py +++ b/rendercanvas/asyncio.py @@ -1,6 +1,6 @@ """Implements an asyncio event loop.""" -# This is used for GUI backends that don't have an event loop by themselves, like glfw. +# This is used for backends that don't have an event loop by themselves, like glfw. # Would be nice to also allow a loop based on e.g. Trio. But we can likely fit that in # when the time comes. diff --git a/rendercanvas/auto.py b/rendercanvas/auto.py index acd00df..88ca771 100644 --- a/rendercanvas/auto.py +++ b/rendercanvas/auto.py @@ -1,5 +1,5 @@ """ -Automatic GUI backend selection. +Automatic backend selection. Right now we only chose between GLFW, Qt and Jupyter. We might add support for e.g. wx later. Or we might decide to stick with these three. @@ -18,7 +18,7 @@ def _load_backend(backend_name): - """Load a gui backend by name.""" + """Load a backend by name.""" if backend_name == "glfw": from . import glfw as module elif backend_name == "qt": @@ -167,9 +167,9 @@ def backends_by_imported_modules(): def backends_by_trying_in_order(): - """Generate backend names by trying to import the GUI lib in order. This is the final fallback.""" + """Generate backend names by trying to import the corresponding lib in order. This is the final fallback.""" - gui_lib_to_backend = { + lib_to_backend = { "glfw": "glfw", "PySide6": "qt", "PyQt6": "qt", @@ -178,7 +178,7 @@ def backends_by_trying_in_order(): # "wx": "wx", } - for libname, backend_name in gui_lib_to_backend.items(): + for libname, backend_name in lib_to_backend.items(): try: importlib.import_module(libname) except ModuleNotFoundError: diff --git a/rendercanvas/base.py b/rendercanvas/base.py index 78a3295..bd63072 100644 --- a/rendercanvas/base.py +++ b/rendercanvas/base.py @@ -86,7 +86,7 @@ def present_image(self, image, **kwargs): class BaseRenderCanvas(RenderCanvasInterface): """The base canvas class. - This class provides a uniform canvas API so render systems can be use + This class provides a uniform canvas API so render systems can use code that is portable accross multiple GUI libraries and canvas targets. Arguments: diff --git a/rendercanvas/glfw.py b/rendercanvas/glfw.py index 5dcad5e..0b11737 100644 --- a/rendercanvas/glfw.py +++ b/rendercanvas/glfw.py @@ -518,11 +518,11 @@ def _on_char(self, window, char): def present_image(self, image, **kwargs): raise NotImplementedError() # AFAIK glfw does not have a builtin way to blit an image. It also does - # not really need one, since it's the most reliable GUI backend to + # not really need one, since it's the most reliable backend to # render to the screen. -# Make available under a name that is the same for all gui backends +# Make available under a name that is the same for all backends RenderCanvas = GlfwRenderCanvas diff --git a/rendercanvas/jupyter.py b/rendercanvas/jupyter.py index 585e686..81b5718 100644 --- a/rendercanvas/jupyter.py +++ b/rendercanvas/jupyter.py @@ -122,7 +122,7 @@ def present_image(self, image, **kwargs): self._last_image = np.frombuffer(image, np.uint8).reshape(image.shape) -# Make available under a name that is the same for all gui backends +# Make available under a name that is the same for all backends RenderCanvas = JupyterRenderCanvas diff --git a/tests/test_scheduling.py b/tests/test_scheduling.py index 347a7c5..3db0d0f 100644 --- a/tests/test_scheduling.py +++ b/tests/test_scheduling.py @@ -80,7 +80,7 @@ def active_sleep(self, delay): self.draw_if_necessary() -def test_gui_scheduling_manual(): +def test_scheduling_manual(): canvas = MyCanvas(min_fps=0.000001, max_fps=100, update_mode="manual") # Booting ... @@ -104,7 +104,7 @@ def test_gui_scheduling_manual(): assert canvas.draw_count == 1 -def test_gui_scheduling_ondemand(): +def test_scheduling_ondemand(): canvas = MyCanvas(min_fps=0.000001, max_fps=100, update_mode="ondemand") # There's a small startup time, so no activity at first @@ -135,7 +135,7 @@ def test_gui_scheduling_ondemand(): assert canvas.events_count == 0 -def test_gui_scheduling_ondemand_always_request_draw(): +def test_scheduling_ondemand_always_request_draw(): # Test that using ondemand mode with a request_draw() in the # draw function, is equivalent to continuous mode. @@ -145,15 +145,15 @@ def test_gui_scheduling_ondemand_always_request_draw(): def draw_func(): canvas.request_draw() - _test_gui_scheduling_continuous(canvas) + _test_scheduling_continuous(canvas) -def test_gui_scheduling_continuous(): +def test_scheduling_continuous(): canvas = MyCanvas(max_fps=10, update_mode="continuous") - _test_gui_scheduling_continuous(canvas) + _test_scheduling_continuous(canvas) -def _test_gui_scheduling_continuous(canvas): +def _test_scheduling_continuous(canvas): # There's a small startup time, so no activity at first canvas.active_sleep(0.001) assert canvas.draw_count == 0 @@ -182,7 +182,7 @@ def _test_gui_scheduling_continuous(canvas): assert canvas.events_count == 0 -def test_gui_scheduling_fastest(): +def test_scheduling_fastest(): canvas = MyCanvas(max_fps=10, update_mode="fastest") # There's a small startup time, so no activity at first