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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8

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

Uploaded CPython 3.8macOS 10.13+ x86-64

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

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.7mmacOS 10.13+ x86-64

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

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6m

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

File metadata

  • Download URL: vpython-7.6.1b6.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.1b6.tar.gz
Algorithm Hash digest
SHA256 f25812210a93bcf043b2897a2260bc8aef0ce7fc19a6daaed2088b1175dc6706
MD5 29f05536cb545edd72af01b68d0f614b
BLAKE2b-256 5f76aeef137bdebe70a2e07a6fd02555e09a6dfa4698c5c95889a14d948cab76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b6-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.1b6-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 588a102f250ac47605140ceae4400ce486827838cd7607bc5568b1add97d4dad
MD5 ef27579bc92a151bfb6cb38c424488fa
BLAKE2b-256 d2b53813331eff8c68988b7a4faeea6b035ac23ffbaeafa6131274f812184662

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for vpython-7.6.1b6-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6c716d5713a9089188ae95b4f4059d67c5810c296700e044cd56721f73d08cfb
MD5 dcdab15574034c6cd2429216883d6bb6
BLAKE2b-256 45e53485ee1b2d23e1438c8c9404392e58a640d1f14cdfccfad79b842fa27b49

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b6-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.1b6-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 875d44f5e2a6144a3dab226d507d1bcc43e701b147240cce080d53d8f553a42b
MD5 ea96d96f60c41c0e950ade0e5067dbfb
BLAKE2b-256 7d078eae95d362c5aa1de33e4c102fce8891c990de92bc5297ab0d283a5ec7d5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b6-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.1b6-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 04517873e948347e984a549d85978d14d1cc8b81787a0ad1d05834e2082a6cfc
MD5 eee26a5d803d21ff7d693e474a91d511
BLAKE2b-256 8c03c2f05be436172a7439e58acb5fff8898702f2e0bb7b96eb1f28af5e13729

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for vpython-7.6.1b6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fb27a2e60fb0d76183391ba6dc59a1f46e0661bb747b019094d8ae0a6b46de1f
MD5 4c483ce08871c4d615cbcafdd3c46ef5
BLAKE2b-256 33f70e2eba396403d9dea670fb397db52f77fd4446d1fbf398b3f7f32cbc3334

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b6-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.1b6-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6f6f26721f478cef0c4ac3181b7475dfffc4d2f3ee4e185649d669b0d67ef25a
MD5 2a7c773e69dbfbb0898eb34bae1da814
BLAKE2b-256 717466328c9858399dfa254831398f514c521ad40b0170d8cdf0fbb79be5949b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b6-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.1b6-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 52205838837d7c8e945f6f446f28488966a5d014b97bce8bd63837efc98f6210
MD5 233bf1d9f6ada28775f2e5022e0229e2
BLAKE2b-256 8d7873a279a32fc82bf1c34e4ad64552b1f95ccaedbd45aaa72baba71e7af723

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for vpython-7.6.1b6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f25bd658499b8d03f466d9f543f2ccf0ba5d36fead4d1d60e0ad9d931df203c8
MD5 b57857b9ca3f09758a6ec5c42e771ef4
BLAKE2b-256 bbc6098bf2ee09e84a22b11ccd31e6d94e13f5036d2de9736eb6387f3f2e5f5d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vpython-7.6.1b6-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.1b6-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6fefbf481f3215cb424d803b37709adb349d6ba166c000f7fe2fa99fdce90b9c
MD5 f4cf7837b0e511e527b92730ec2c5b63
BLAKE2b-256 a4e85b6689aea7a6dab8730d7e7e808e80f6f11b21cb35dfb6d06ee44d73c6b7

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