pygfx.objects.EventTarget

class pygfx.objects.EventTarget(*args, **kwargs)

Bases: object

Targetable object mixin.

Mixin class that enables event handlers to be attached to objects of the mixed-in class.

Parameters:
  • args (Any) – Arguments are forwarded to allow multiple inheritance.

  • kwargs (Any) – Kwargs are forwarded to allow multiple inheritance.

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 event types, see https://jupyter-rfb.readthedocs.io/en/stable/events.html

Can also be used as a decorator.

Example:

def my_handler(event):
    print(event)

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

Decorator usage example:

@obj.add_event_handler("pointer_up", "pointer_down")
def my_handler(event):
    print(event)
remove_event_handler(callback, *types)

Unregister an event handler.

Parameters:
  • callback (callable) – The event handler.

  • *types (list of strings) – A list of event types.

handle_event(event: Event)

Handle an incoming event.

Parameters:

event – The event to handle

set_pointer_capture(pointer_id, event_root)

Register this object to capture any other pointer events, until release_pointer_capture is called or an pointer_up event is encountered.

Parameters:
  • pointer_id – id of pointer to capture (mouse, touch, etc.)

  • event_root – the event root that this pointer is captured on

release_pointer_capture(pointer_id)

Release the pointer capture for the object that was registered to the given pointer_id.

Parameters:

pointer_id – id of pointer to release (mouse, touch, etc.)

Examples

Animation Mixer

Animation Mixer

Anisotropy Barn Lamp

Anisotropy Barn Lamp

Ambient occlusion

Ambient occlusion

Clearcoat effect

Clearcoat effect

Clearcoat effect

Clearcoat effect

Colormap Channels

Colormap Channels

Colormap Image

Colormap Image

Colormap Mesh

Colormap Mesh

Minimal Custom Object

Minimal Custom Object

Simple Custom Object

Simple Custom Object

Custom Object

Custom Object

Types of Cylinders

Types of Cylinders

Dynamic Environment Map

Dynamic Environment Map

Earth

Earth

Environment Map Effects

Environment Map Effects

Flat Shading

Flat Shading

Fly controller

Fly controller

Geometry Cubes

Geometry Cubes

Geometry Image

Geometry Image

Klein Bottle Geometry

Klein Bottle Geometry

Möbius strip Geometry

Möbius strip Geometry

Geometry Plane

Geometry Plane

Rotating Polyhedra

Rotating Polyhedra

Subdivision

Subdivision

Torus knot

Torus knot

Animations with glTF

Animations with glTF

glTF Unlit Material Example

glTF Unlit Material Example

Gizmo to transform world objects

Gizmo to transform world objects

Stats helper (Manual)

Stats helper (Manual)

Image Click Events

Image Click Events

Image with another image overlaid

Image with another image overlaid

Image with Points Overlaid

Image with Points Overlaid

Displaying an image in a scene

Displaying an image in a scene

Instancing

Instancing

Iridescence Abalone

Iridescence Abalone

Iridescence

Iridescence

Labelled Image Grid

Labelled Image Grid

Directional Shadow 1

Directional Shadow 1

Directional Shadow 2

Directional Shadow 2

Spotlight Shadow

Spotlight Shadow

Spotlights

Spotlights

Lightmap

Lightmap

Line Drawing

Line Drawing

Line Drawing Performance

Line Drawing Performance

Line plot

Line plot

Line Segments

Line Segments

Thick Lines

Thick Lines

Look At

Look At

Look At (Instanced Mesh)

Look At (Instanced Mesh)

Transform Control without Matrix Updating

Transform Control without Matrix Updating

Map Screen to World

Map Screen to World

Measure distances in 2D

Measure distances in 2D

Measure distances in 3D

Measure distances in 3D

Depth Material

Depth Material

Mesh dynamic

Mesh dynamic

Mesh Slice Material

Mesh Slice Material

Toon Rendering 1

Toon Rendering 1

Toon Rendering 2

Toon Rendering 2

Facecap animation with morph targets

Facecap animation with morph targets

Morph Targets

Morph Targets

Multi-Object Selection

Multi-Object Selection

Volume and Mesh Slicing 1

Volume and Mesh Slicing 1

Mesh and Volume Slicing 2

Mesh and Volume Slicing 2

Multiple Fonts

Multiple Fonts

Paint to a texture

Paint to a texture

Paint to a texture directly

Paint to a texture directly

Panzoom Camera

Panzoom Camera

PBR Rendering 1

PBR Rendering 1

PBR Rendering 2

PBR Rendering 2

PBR Instanced Rendering

PBR Instanced Rendering

Physical Color

Physical Color

Color Picking

Color Picking

Mesh Picking

Mesh Picking

Point Picking

Point Picking

Point Markers with Multiple Colors

Point Markers with Multiple Colors

Simulating grass with point sprites

Simulating grass with point sprites

Mesh with quads

Mesh with quads

Camera linking 1

Camera linking 1

Camera linking 2

Camera linking 2

Nested Scenes

Nested Scenes

Scene Overlay

Scene Overlay

Subplots 1

Subplots 1

Subplots 2

Subplots 2

Subplots Video

Subplots Video

Sheen Chair

Sheen Chair

Glam Velvet Sofa

Glam Velvet Sofa

Show Image

Show Image

Use gfx.show to show a Scene

Use gfx.show to show a Scene

Skinned Mesh

Skinned Mesh

Skinning Animation

Skinning Animation

Detached Bind Mode

Detached Bind Mode

Use a Skybox

Use a Skybox

Use a Skybox

Use a Skybox

Sphere Geometry

Sphere Geometry

Synced Video Rendering

Synced Video Rendering

Text align

Text align

Big static text

Big static text

Text contrast

Text contrast

Text multiple grid

Text multiple grid

Text multiple labels

Text multiple labels

Text snake

Text snake

Text waterfall

Text waterfall

Transparency 1

Transparency 1

Transparency 2

Transparency 2

Video YUV

Video YUV

Isosurface Volume Rendering

Isosurface Volume Rendering

Minip Volume Rendering

Minip Volume Rendering

Volume Rendering 1

Volume Rendering 1

Volume Rendering 2

Volume Rendering 2

Volume Slice 1

Volume Slice 1

Volume Slice 2

Volume Slice 2

Volume Slice 3

Volume Slice 3

Wireframe 1

Wireframe 1

Wireframe 2

Wireframe 2

Wireframe Material

Wireframe Material

Bounding Box Coordinates

Bounding Box Coordinates

Clipping Planes

Clipping Planes

Hello World

Hello World

Hello text

Hello text

Render a Triangle

Render a Triangle

Lights

Lights

Boundary Boxes

Boundary Boxes

Offscreen Rendering

Offscreen Rendering

Orbit Camera

Orbit Camera

Rendering Points

Rendering Points

Use gfx.show

Use gfx.show

A Tool to Compare Two Images of Identical Shapes

A Tool to Compare Two Images of Identical Shapes

Additive Blending

Additive Blending

Validate transparency with and without bg

Validate transparency with and without bg

Validate dither

Validate dither

Validate transparency for the ordered2 blend mode

Validate transparency for the ordered2 blend mode

Validate weighted_plus

Validate weighted_plus

Box Geometry

Box Geometry

Reference Color

Reference Color

Culling

Culling

Depth Clipping

Depth Clipping

Depth Overlay 1

Depth Overlay 1

Depth Overlay 2

Depth Overlay 2

Validate the grid

Validate the grid

Axes Helper 1

Axes Helper 1

Axis Helper 2

Axis Helper 2

Image on Plane Geometry 1

Image on Plane Geometry 1

Image Material

Image Material

Validate Colormap

Validate Colormap

Light and Shadow

Light and Shadow

Lines in 2D

Lines in 2D

Dashing

Dashing

Lines with different thicknesses

Lines with different thicknesses

Lines drawn with different thickness_space

Lines drawn with different thickness_space

Mesh Colormaps

Mesh Colormaps

Mesh slice

Mesh slice

NDC Coordinates

NDC Coordinates

Normals on front and back

Normals on front and back

Points with different markers

Points with different markers

Points with different sizes

Points with different sizes

Points drawn with different size_space

Points drawn with different size_space

Validate ruler

Validate ruler

Validate send_data

Validate send_data

Validate Skybox

Validate Skybox

srgb texture colorspace

srgb texture colorspace

Text alignment

Text alignment

Text anchor

Text anchor

Text direction

Text direction

Text markdown formatting

Text markdown formatting

Text outline always behind text itself

Text outline always behind text itself

Text size

Text size

Tiny Image Validation

Tiny Image Validation

Validate transforms

Validate transforms

Validate view offset

Validate view offset

Volume and Volume Slice Rendering

Volume and Volume Slice Rendering