wgpu.gui.WgpuAutoGui¶
- class wgpu.gui.WgpuAutoGui(*args, **kwargs)¶
Bases:
objectMixin class for canvases implementing autogui.
AutoGui canvases provide an API for handling events and registering event handlers.
- add_event_handler(*args)¶
Register an event handler.
- Parameters:
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
Can also be used as a decorator.
Example:
def my_handler(event): print(event) canvas.add_event_handler(my_handler, "pointer_up", "pointer_down")
Decorator usage example:
@canvas.add_event_handler("pointer_up", "pointer_down") def my_handler(event): print(event)
Catch ‘m all:
canvas.add_event_handler(my_handler, "*")
- handle_event(event)¶
Handle an incoming event.
Subclasses can overload this method. Events include widget resize, mouse/touch interaction, key events, and more. An event is a dict with at least the key event_type. For details, see https://jupyter-rfb.readthedocs.io/en/stable/events.html
The default implementation dispatches the event to the registered event handlers.
- remove_event_handler(callback, *types)¶
Unregister an event handler.
- Parameters:
callback (callable) – The event handler.
*types (list of strings) – A list of event types.