vispy.scene.widgets.viewbox module

class vispy.scene.widgets.viewbox.ViewBox(camera=None, **kwargs)

Bases: vispy.scene.widgets.widget.Widget

Provides a rectangular widget to which its subscene is rendered.

Three classes work together when using a ViewBox: * The SubScene class describes a “world” coordinate system and the entities that live inside it. * ViewBox is a “window” through which we view the subscene. Multiple ViewBoxes may view the same subscene. * Camera describes both the perspective from which the subscene is rendered, and the way user interaction affects that perspective.

In general it is only necessary to create the ViewBox; a SubScene and Camera will be generated automatically.

Parameters
camerainstance of Camera | str | None

The camera through which to view the SubScene. If None, then a PanZoomCamera (2D interaction) is used. If str, then the string is used as the argument to make_camera().

**kwargsdict

Extra keyword arguments to pass to Widget.

add(node)

Add an Node to the scene for this ViewBox.

This is a convenience method equivalent to node.parent = viewbox.scene

Parameters
nodeinstance of Node

The node to add.

property camera

Get/set the Camera in use by this ViewBox

If a string is given (e.g. ‘panzoom’, ‘turntable’, ‘fly’). A corresponding camera is selected if it already exists in the scene, otherwise a new camera is created.

The camera object is made a child of the scene (if it is not already in the scene).

Multiple cameras can exist in one scene, although only one can be active at a time. A single camera can be used by multiple viewboxes at the same time.

get_scene_bounds(dim=None)

Get the total bounds based on the visuals present in the scene

Parameters
dimint | None

Dimension to return.

Returns
boundslist | tuple

If dim is None, Returns a list of 3 tuples, otherwise the bounds for the requested dimension.

is_in_scene(node)

Get whether the given node is inside the scene of this viewbox.

Parameters
nodeinstance of Node

The node.

on_resize(event)

Resize event handler

Parameters
eventinstance of Event

The event.

property scene

The root node of the scene viewed by this ViewBox.