Skip to main content

VPython for Jupyter Notebook

Project description

VPython

This package enables one to run VPython in a browser, using the GlowScript VPython API, documented in the Help at https://www.glowscript.org. If the code is in a cell in a Jupyter notebook, the 3D scene appears in the Jupyter notebook. If the code is launched outside a notebook (e.g. from the command line), a browser window will open displaying the scene.

VPython makes it unusually easy to create navigable real-time 3D animations. The one-line program "sphere()" produces a 3D sphere with appropriate lighting and with the camera positioned so that the scene fills the view. It also activates mouse interactions to zoom and rotate the camera view. This implementation of VPython was begun by John Coady in May 2014. Ruth Chabay, Matt Craig, and Bruce Sherwood are assisting in its further development.

Installation

For more detailed instructions on how to install vpython, see https://vpython.org, where you will also find a link to the VPython forum, which is a good place to report issues and to request assistance.

Briefly:

  • If you use the anaconda python distribution, install like this: conda install -c vpython vpython
  • If you use any other python distribution, install this way: pip install vpython

Sample program

Here is a simple example:

from vpython import *
sphere()

This will create a canvas containing a 3D sphere, with mouse and touch controls available to zoom and rotate the camera:

Right button drag or Ctrl-drag to rotate "camera" to view scene.
To zoom, drag with middle button or Alt/Option depressed, or use scroll wheel.
     On a two-button mouse, middle is left + right.
Shift-drag to pan left/right and up/down.
Touch screen: pinch/extend to zoom, swipe or two-finger rotate.

Currently, to re-run a VPython program in a Jupyter notebook you need to click the circular arrow icon to "restart the kernel" and then click the red-highlighted button, then click in the first cell, then click the run icon. Alternatively, if you insert "scene = canvas()" at the start of your program, you can rerun the program without restarting the kernel.

Run example VPython programs: Binder

vpython build status (for the vpython developers)

Build Status Build status

Working with the source code

Here is an overview of the software architecture:

https://vpython.org/contents/VPythonArchitecture.pdf

The vpython module uses the GlowScript library (vpython/vpython_libraries/glow.min.js). The GlowScript repository is here:

https://github.com/vpython/glowscript

In the GlowScript repository's docs folder, GlowScriptOverview.txt provides more details on the GlowScript architecture.

Here is information on how to run GlowScript VPython locally, which makes possible testing changes to the GlowScript library:

https://www.glowscript.org/docs/GlowScriptDocs/local.html

If you execute build_original_no_overload.py, and change the statement "if True:" to "if False", you will generate into the ForInstalledPython folder an un-minified glow.min.js which can be copied to site-packages/vpython/vpython_libraries and tested by running your test in (say) idle or spyder. (Running in Jupyter notebook or Jupyterlab requires additional fiddling.)

Note that in site-packages/vpython/vpython_libraries it is glowcomm.html that is used by launchers such as idle or spyder; glowcomm.js is used with Jupyter notebook (and a modified version is used in Jupyterlab).

Placing console.log(....) statements in the GlowScript code or in the JavaScript section of glowcomm.html can be useful in debugging. You may also need to put debugging statements into site-packages/vpython/vpython.py.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vpython-7.6.1b7.tar.gz (3.6 MB view details)

Uploaded Source

Built Distributions

vpython-7.6.1b7-cp38-cp38-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.8Windows x86-64

vpython-7.6.1b7-cp38-cp38-manylinux1_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.8

vpython-7.6.1b7-cp38-cp38-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.8macOS 10.13+ x86-64

vpython-7.6.1b7-cp37-cp37m-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.7mWindows x86-64

vpython-7.6.1b7-cp37-cp37m-manylinux1_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.7m

vpython-7.6.1b7-cp37-cp37m-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.7mmacOS 10.13+ x86-64

vpython-7.6.1b7-cp36-cp36m-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.6mWindows x86-64

vpython-7.6.1b7-cp36-cp36m-manylinux1_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.6m

vpython-7.6.1b7-cp36-cp36m-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.6mmacOS 10.13+ x86-64

File details

Details for the file vpython-7.6.1b7.tar.gz.

File metadata

  • Download URL: vpython-7.6.1b7.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b7.tar.gz
Algorithm Hash digest
SHA256 da54f293b75773ca64e0a682acdc2b7a47a3f00e29b91468a4f204bfddb15e0f
MD5 67161fdc57727cba0450154b29e71896
BLAKE2b-256 d2b3569c36cf10d4e8c86c68cc10478b7cd18071cee64eb7702e49463cced1ec

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b7-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: vpython-7.6.1b7-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b7-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e0cc19e5266b326178e37a13f7bce255104b4987b01cc4052c55626674dcba00
MD5 6f60f81ff0d73e29660b581195695f82
BLAKE2b-256 0bbb6775a72dcc376c01b1324136b0dbe9d537e05d28abbe989715e67f517304

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b7-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b7-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b7-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 871b854d3dd96347a696406c400de33447a5903ee54309a395dc121db663e79c
MD5 7420ea55553db1dfdf1418c6dc552843
BLAKE2b-256 f7c6eadcf3c547da6afa71c6b5fd6e1e9ee418587ede792219f61da2b2573420

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b7-cp38-cp38-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b7-cp38-cp38-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.8, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b7-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 406f07ef52877bef89f900080509e047d44e98584713f608bd56cccc3a3e76a8
MD5 3734bd9c991865a7a037fe0af04c4ded
BLAKE2b-256 76652c2036ed6fa7360117eac50657524cafaed0a82e23cda31c18759d5c6f49

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b7-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: vpython-7.6.1b7-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.6

File hashes

Hashes for vpython-7.6.1b7-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 258fcfb966682fdcabed9a0de9100beaa3cc893bbb24d97027eed496ba640af0
MD5 a8285083534a5796145460c031f1c88d
BLAKE2b-256 7374fac7b2990b9e85a6a0287800aa2ef05d166d541c8817d6e7c0bb5a695e80

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b7-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b7-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b7-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a724085fb7e58e1bdee1a730b88bc48210ffa3bf2dc2b4ae5141656ff8a6ada3
MD5 877f30e00d0b066e62fd20b80a9db4fc
BLAKE2b-256 b01336c6c7094ca0ed28375983cf4f92ee5eac1ce7d4294d1594059363406abe

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b7-cp37-cp37m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b7-cp37-cp37m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.7m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.6

File hashes

Hashes for vpython-7.6.1b7-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 14ea388b24d83f8d295581cd9ae41bc48ae759731065273533153d600703c615
MD5 ed86f2caea9f705d4cc4406f8d4ae1cf
BLAKE2b-256 9a0732db7569f32beb34cfafc15e2e9b7bcecbd7fbd03db6d4d7f6c525117999

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b7-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: vpython-7.6.1b7-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.8

File hashes

Hashes for vpython-7.6.1b7-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 621db402412c878dff02ac733cb8fbae89a16968d7ba183262c8f90596f1e049
MD5 6f041504878bdf91655113ffe2d6f1d7
BLAKE2b-256 4e7ce2b0e1b13edc5f141d3cc9f6e5cb583fba14263d91f5069b08cd3136de8a

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b7-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b7-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b7-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 596e442b092f61844ea11269af35be33875551e8dedac49cac050caec870abc3
MD5 04d033c5278103bd9289d4fcd694cffe
BLAKE2b-256 c91d2fde3cf3a757fa2f70caebb499c00e00fd6920012d8e721447ec1443324e

See more details on using hashes here.

File details

Details for the file vpython-7.6.1b7-cp36-cp36m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b7-cp36-cp36m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.6m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.10

File hashes

Hashes for vpython-7.6.1b7-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4701ffff1801cc2190c33ae0c14bd67ff431ac3ffcfa1da47c5625c131f6a10f
MD5 b27f973d717f49ec12f29370fa0bbf33
BLAKE2b-256 0ee0fd9869b1a0590256baa41a08f8d2f76e207435207b53595a226dd42e50b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page