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.1b4.tar.gz (3.6 MB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8macOS 10.13+ x86-64

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

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7mmacOS 10.13+ x86-64

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

Uploaded CPython 3.6mWindows x86-64

vpython-7.6.1b4-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.1b4.tar.gz.

File metadata

  • Download URL: vpython-7.6.1b4.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.41.1 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b4.tar.gz
Algorithm Hash digest
SHA256 ac2b970c7b9d84f81aacedc8a699d728d81ee9779ea79e9c62877aacbf5390c0
MD5 bc4dc8013f30ef36ccfc9f4c392eac79
BLAKE2b-256 daac4a8e9de322b71c3b1023de30fa464785db74e94661f16ee316473b06ddf8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b4-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.41.1 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5f5e015489dff434a750051a1d6020c2ebe1cfdad7a7c9184c8e4470924d27f7
MD5 63ec9daa2b9efd939bd167b691832da9
BLAKE2b-256 ca778cc9295c84abab78937a055e9465f08b3aa90b7ada4bec6506de2ef51367

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b4-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.41.1 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b4-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f64fcd659bb53cf2f8842f93e5b66fa9595e17a7aa9542fdf7a03f2fd6c8564f
MD5 9f0b98f4b40e89ba40a969a9e707880c
BLAKE2b-256 1f94217e5376f3fb822184cd0839ab9c00ee7a9d264f476310346146ccbc1687

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b4-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.41.1 CPython/3.7.6

File hashes

Hashes for vpython-7.6.1b4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 818f561a09d13b2f2ec346523fa6c31f1abcc5e4921d617e1343b3682d743c32
MD5 ab585b3d3a8902b83e12a53ff19bff9f
BLAKE2b-256 9f3a077132383fe9b7eb02c53bfb0f10064dd14bf6c737affd17fdece88a17d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b4-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.41.1 CPython/3.7.6

File hashes

Hashes for vpython-7.6.1b4-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a040178aeeeb2084fc3bdd29dea1e65e4e6909a9941c657828a4676c2f443c1c
MD5 ebfa49f5237b043ad38b79a3b4982683
BLAKE2b-256 aefc74cf89f8044a97ffcc9e3d2be062c856062aa79c77068692e600d7c5df25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b4-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.41.1 CPython/3.6.8

File hashes

Hashes for vpython-7.6.1b4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 7dca25e407b1bed0d966be6b7f5bb5023f20873c2602cfff199dcde540b2ceb9
MD5 60cf5cd5885589f5c2c29db9f061bcd3
BLAKE2b-256 054202663ce3189fd2c76dacbcbf4cd4cbc1824e6eb2536dd6b97c475578769d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b4-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.41.1 CPython/3.6.10

File hashes

Hashes for vpython-7.6.1b4-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3173c116b2dcbf9f60ff9c273bf97de79c205b61d098b5fee71f1ef1b71021e9
MD5 d71776ef1dc80d04bab4fa7f0e2f792c
BLAKE2b-256 6abcb9b1e5ac72ae321093a790f9ba15819393593b3a1ab97e7736d288cae2ca

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