Skip to content

Commit

Permalink
Warn about refs in add_event_handler
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Oct 24, 2023
1 parent b68d2bf commit 77f8fa7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions wgpu/gui/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,19 @@ def handle_event(self, event):
callback(event)

def add_event_handler(self, *args):
"""Register an event handler.
"""Register an event handler to receice 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 @@ -322,7 +324,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

0 comments on commit 77f8fa7

Please sign in to comment.