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