add_event_handler#

Graphic.add_event_handler(*args)[source]#

Register an event handler. Can also be used as a decorator.

Parameters:
  • callback (callable, the first argument) – Event handler, must accept a single event argument

  • *types (strings) –

    event types, ex: “click”, “data”, “colors”, “pointer_down”

    supported_events will return a tuple of all event type strings that this graphic supports. See the user guide in the documentation for more information on events.

Example

def my_handler(event):
    print(event)

graphic.add_event_handler(my_handler, "pointer_up", "pointer_down")

Decorator usage example:

@graphic.add_event_handler("click")
def my_handler(event):
    print(event)

Examples#

Drag points

Drag points

Image click event

Image click event

Image data event

Image data event

Events line data thickness

Events line data thickness

Paint an Image

Paint an Image

Scatter click

Scatter click

Scatter hover

Scatter hover

Scatter data explore scalers

Scatter data explore scalers

Sine and Cosine functions

Sine and Cosine functions

Explore Covariance Matrix

Explore Covariance Matrix

K-Means Clustering of MNIST Dataset

K-Means Clustering of MNIST Dataset

Explore fourier transform of images

Explore fourier transform of images

LinearRegionSelectors with LineCollection

LinearRegionSelectors with LineCollection

LinearRegionSelectors

LinearRegionSelectors

Linear Selectors

Linear Selectors

Linear Selectors Image

Linear Selectors Image

Rectangle Selectors

Rectangle Selectors

Rectangle Selectors Images

Rectangle Selectors Images

Unit circle

Unit circle