Skip to content

Commit

Permalink
Rename WgpuEventType -> EventType
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Nov 6, 2024
1 parent 4cd1285 commit f817810
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/gui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:


Expand Down
4 changes: 2 additions & 2 deletions rendercanvas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
8 changes: 4 additions & 4 deletions rendercanvas/_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions rendercanvas/base.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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'.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit f817810

Please sign in to comment.