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

Uploaded Source

Built Distributions

vpython-7.5.2b1-py3.7-linux-x86_64.egg (3.8 MB view details)

Uploaded Egg

vpython-7.5.2b1-cp37-cp37m-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.7mWindows x86-64

vpython-7.5.2b1-cp37-cp37m-win32.whl (3.6 MB view details)

Uploaded CPython 3.7mWindows x86

vpython-7.5.2b1-cp37-cp37m-macosx_10_9_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

vpython-7.5.2b1-cp36-cp36m-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.6mWindows x86-64

vpython-7.5.2b1-cp36-cp36m-win32.whl (3.6 MB view details)

Uploaded CPython 3.6mWindows x86

vpython-7.5.2b1-cp36-cp36m-macosx_10_7_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.6mmacOS 10.7+ x86-64

File details

Details for the file vpython-7.5.2b1.tar.gz.

File metadata

  • Download URL: vpython-7.5.2b1.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for vpython-7.5.2b1.tar.gz
Algorithm Hash digest
SHA256 eebef03ae81ad7ce2e1ed7d6230f6aab56cc39c267b422a4924b86924b306ead
MD5 e7403959a93c0b6634d0d5aae4278503
BLAKE2b-256 b02cb1b11cc11045b2083e1bdb92271bb14bd6db6caf7247d073a6f1e468611c

See more details on using hashes here.

File details

Details for the file vpython-7.5.2b1-py3.7-linux-x86_64.egg.

File metadata

  • Download URL: vpython-7.5.2b1-py3.7-linux-x86_64.egg
  • Upload date:
  • Size: 3.8 MB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for vpython-7.5.2b1-py3.7-linux-x86_64.egg
Algorithm Hash digest
SHA256 bebbff354d2eead18ea9bd1dcf123098d7de18b89b7a19e1484faa74d194c7dc
MD5 ecd535fa1af863df66ff563dff6dbc18
BLAKE2b-256 9752dde7d917a86d65540cf3d664a81345119e52ed439238baf2787c17b07e01

See more details on using hashes here.

File details

Details for the file vpython-7.5.2b1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: vpython-7.5.2b1-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/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for vpython-7.5.2b1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 575661d7aeb5a1cd0f95c5198e83de26a175f9ad187f41cce01e4506195911c5
MD5 af2f750edda7b80023d7e51ab500f11e
BLAKE2b-256 7544de1c3113ea93885b0cf4ef0400621dfbd97fabcebed7b1fb711767a6d99b

See more details on using hashes here.

File details

Details for the file vpython-7.5.2b1-cp37-cp37m-win32.whl.

File metadata

  • Download URL: vpython-7.5.2b1-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for vpython-7.5.2b1-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 accf6bcb65c83de3cc1da564186616e6b8ab0bb05bbd7c7ee99f79fa6593c025
MD5 c5d8fcc3b08d080c7ca0d098f9b01cdb
BLAKE2b-256 764ac579df516f61131352f53c1559c2d433eae1093b674db0af11059b11de8c

See more details on using hashes here.

File details

Details for the file vpython-7.5.2b1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: vpython-7.5.2b1-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for vpython-7.5.2b1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 09f8b8f753358b77584324fc675c361047dfd7db6d1925ff168bc74c1544f45c
MD5 aa22ac895219fa2916b45452e4b9b04d
BLAKE2b-256 df8f84bed70e7a8a2f1b84adb752041fb9b09bc416cd1b7d7fe7323d59cf78b9

See more details on using hashes here.

File details

Details for the file vpython-7.5.2b1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: vpython-7.5.2b1-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/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.5

File hashes

Hashes for vpython-7.5.2b1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a4d8a665cc5ae677f2847d6e9ea0daf3a82ea4820c53ab9c9037ffe0fd47c455
MD5 c9ee8d57cb7052082631d79687669a1b
BLAKE2b-256 e883af329c3e6c9c1d21e74fa628a73e5e6208a7ea20b54346cc29116993dd8d

See more details on using hashes here.

File details

Details for the file vpython-7.5.2b1-cp36-cp36m-win32.whl.

File metadata

  • Download URL: vpython-7.5.2b1-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.5

File hashes

Hashes for vpython-7.5.2b1-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 2af477bca0b38577b5b9ab462055c2429d31debebffa193ff8dc966267476416
MD5 3bfbe9e2183503cdfda8ec260a694fd6
BLAKE2b-256 3bba3f0539ba0ddd72bea180b759eb3b2a26894da774935227e2ca502ec7964f

See more details on using hashes here.

File details

Details for the file vpython-7.5.2b1-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: vpython-7.5.2b1-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for vpython-7.5.2b1-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 e7d554a0825eb3f98f11d3a809d89b29dd297901d220be7560122a3f8019bf2a
MD5 43201654ec3153bc592c6885dd5b49ea
BLAKE2b-256 1f5d1bb1c3aed5839211f95c195afd4cfb2afcd17a606a0c7ee245985e67bbf9

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