Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about refs in add_event_handler #398

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions wgpu/gui/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,19 @@ def handle_event(self, event):
callback(event)

def add_event_handler(self, *args):
"""Register an event handler.
"""Register an event handler to receive events.
Arguments:
callback (callable): The event handler. Must accept a
single event argument.
callback (callable): The event handler. Must accept a single event argument.
*types (list of strings): A list of event types.
For the available events, see
https://jupyter-rfb.readthedocs.io/en/stable/events.html
https://jupyter-rfb.readthedocs.io/en/stable/events.html.
Can also be used as a decorator.
The callback is stored, so it can be a lambda or closure. This also
means that if a method is given, a reference to the object is held,
which may cause circular references or prevent the Python GC from
destroying that object.
Example:
Expand All @@ -326,7 +328,7 @@ def my_handler(event):
canvas.add_event_handler(my_handler, "pointer_up", "pointer_down")
Decorator usage example:
Can also be used as a decorator:
.. code-block:: py
Expand Down
Loading