Getting Started with Vpython and Jupiter Notebooks

288 views
Skip to first unread message

Nicholas Gross

unread,
Apr 21, 2018, 1:13:24 AM4/21/18
to VPython-users
I am just getting started with these. 
I can run the code below and it seems to work just fine, but when I try to re-evaluate that cell in the notebook, it closes the original scene and does not reopen a new one.  Any thoughts?

====
from vpython import *
box()
sphere()
===
Message has been deleted

Bruce Sherwood

unread,
Apr 21, 2018, 9:34:13 AM4/21/18
to VPython-users
Here are the instructions, from vpython.org:

  Write a test program: This short program will display a white box on a black background:

from vpython import *
box()

Running a VPython program in a Jupyter notebook: Click in the first cell (containing the vpython import statement), then click the run icon, the one that is a rightward-facing triangle touching a vertical line. Currently, to re-run a VPython program 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.

Some users find it convenient to iinclude in the first cell just these statements:
from vpython import*
scene = canvas()

Then put the rest of the program in later cells. The result is that the 3D display will be shown just under the first cell instead of at the end of the last cell. It also ensures that the vpython module has been fully initialized before continuing. Moreover, you can re-run the program more easily.

Reply all
Reply to author
Forward
0 new messages