Package Scientific :: Package Visualization :: Module VPython :: Class Scene

[frames] | no frames]

# Class Scene

VPython scene

A VPython scene is a collection of graphics objects that can be shown in a VPython window. When the "view" method is called, a new window is created and the graphics objects are displayed in it.

Instance Methods

GraphicsObject

__getitem__(self, item) Returns: the graphics object at the index position |

__init__(self, objects=None, **options) |

`int`

__len__(self) Returns: the number of graphics objects in the scene |

addObject(self, object) |

view(self) Open a VPython window for the scene |

Method Details

### __getitem__(self, item)
(Indexing operator)

Parameters:
  - `item` (`int`) - an index
Returns: GraphicsObject
  the graphics object at the index position

### __init__(self, objects=None, **options)
(Constructor)

Parameters:
  - `objects` (`list` or `NoneType`) - a list of graphics objects, or `None` for an empty scene
  - `options` - options as keyword arguments
  - `title` (`str`) - the window title (default: "VPython scene")
  - `width` (`int`) - the window width in pixels (default: 300)
  - `height` (`int`) - the window height in pixels (default: 300)
  - `background` (`str`) - the background color (default: "black")

### __len__(self)
(Length operator)

Returns: `int`
  the number of graphics objects in the scene

### addObject(self, object)

Parameters:
  - `object` (GraphicsObject) - a graphics object to be added to the scene