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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

vpython-7.6.1b1-cp38-cp38-macosx_10_9_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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

Uploaded CPython 3.7m Windows x86-64

vpython-7.6.1b1-cp37-cp37m-win32.whl (3.5 MB view details)

Uploaded CPython 3.7m Windows x86

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

Uploaded CPython 3.7m macOS 10.9+ x86-64

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

Uploaded CPython 3.6m Windows x86-64

vpython-7.6.1b1-cp36-cp36m-win32.whl (3.5 MB view details)

Uploaded CPython 3.6m Windows x86

vpython-7.6.1b1-cp36-cp36m-macosx_10_9_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file vpython-7.6.1b1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.1

File hashes

Hashes for vpython-7.6.1b1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4c5ba52641e29ceda3d9f8a333b42387958a47f10ead599574067f46dcb61fcc
MD5 0304ff5f2bbce022b60c2ad9fdd739ad
BLAKE2b-256 224a20644fb0bf5d711d8d9f8b010ec0e498e5d85460380c993edd9dc4f69941

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: vpython-7.6.1b1-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/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4

File hashes

Hashes for vpython-7.6.1b1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 449c38bd7b33fd22ba0fb2fb5a14adbd242b8d4d6b37bee48088c1eb394f798b
MD5 2a7cedd27bb8ba747b5c275ad479489e
BLAKE2b-256 e38d9e0ee006b2e694ddbc74460953b0db026aa8f78163fe5df880cf7c693734

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: vpython-7.6.1b1-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4

File hashes

Hashes for vpython-7.6.1b1-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 bf1dbbb637e76cee9932f2a2679fd7efe1b8480e44783e0b6a981fc28e2a64df
MD5 cda2ee6ac298e415ef2131ec56647720
BLAKE2b-256 39887bc22fdf5751872a1d04e2638e240cb1a62f63afdb37ef1e9d553f2fe76f

See more details on using hashes here.

Provenance

File details

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

File metadata

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

File hashes

Hashes for vpython-7.6.1b1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6579c8bc55bf860df9243d940481c7efed51edb53b73b3632066e0bc39623fec
MD5 3f6153021c7837db60cc344dc7b38aad
BLAKE2b-256 32c2da9716efacd317e065444d8990022dcdce78d4eeadf1c8759451739f4b6e

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: vpython-7.6.1b1-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/39.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.5

File hashes

Hashes for vpython-7.6.1b1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 b2c609fb12062c84f17a7f44a89190a18538ea6ff89b8309edb615063e4bb529
MD5 9e378ecffe3db5542956f619ec0a4367
BLAKE2b-256 677a75686ce9d6228ac70f2d968a89522baf8161ff8d8acfe47c08137babe3a5

See more details on using hashes here.

Provenance

File details

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

File metadata

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

File hashes

Hashes for vpython-7.6.1b1-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 21207eb9dea34e209f7da7b5a2b11f854f3378bf8a4eedc856c60cc543ae942e
MD5 d2924c38d3e00c5a13de8c9cd2ceae17
BLAKE2b-256 7c436771bc3d3c29783ae49fee4ff6036161e3c07407053edf2e0bda704ed3ab

See more details on using hashes here.

Provenance

File details

Details for the file vpython-7.6.1b1-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: vpython-7.6.1b1-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9

File hashes

Hashes for vpython-7.6.1b1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f66c455562789a34f9860c76cd823dedcc268bfad030d1344027f3f7074fcdd4
MD5 96afde9eee1174e04814ed0ea7781116
BLAKE2b-256 df31e2f14c1b14f41ca0449a85b4ba983ba6944ec3b9def7252ed1b03d9b460a

See more details on using hashes here.

Provenance

Supported by

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