VPython脚本的输出是什么?为什么对我来说它是用镀铬的?
每当我使用vpython库运行脚本时,可视化就会在google chrome选项卡中打开VPython脚本的输出是什么?为什么对我来说它是用镀铬的?,python,vpython,Python,Vpython,每当我使用vpython库运行脚本时,可视化就会在google chrome选项卡中打开 我想知道为什么会出现这种情况,以及vpython可视化的输出是什么,它将在Chrome选项卡中打开。好吧,如果打开站点包/vpython/no_notebook.py,您将看到: import webbrowser as _webbrowser 就这样 在幕后,它在“无jupyter笔记本模式”中的作用是启动一个线程本地HTTP服务器,提供一些javascript,然后在web浏览器中打开一个页面连接到该
我想知道为什么会出现这种情况,以及vpython可视化的输出是什么,它将在Chrome选项卡中打开。好吧,如果打开
站点包/vpython/no_notebook.py
,您将看到:
import webbrowser as _webbrowser
就这样
在幕后,它在“无jupyter笔记本模式”中的作用是启动一个线程本地HTTP服务器,提供一些javascript,然后在web浏览器中打开一个页面连接到该服务器。其余的只是服务器和客户机之间的数据交换,就像任何其他web应用程序一样
有关数据交换的更详细说明,请参见站点包/vpython/vpython.py
:
# Now there is no threading in Jupyter VPython. Data is sent to the
# browser from the trigger() function, which is called by a
# canvas_update event sent to Python from the browser (glowcomm.js), currently
# every 33 milliseconds. When trigger() is called, it immediately signals
# the browser to set a timeout of 33 ms to send another signal to Python.
# Note that a typical VPython program starts out by creating objects (constructors) and
# specifying their attributes. The 33 ms signal from the browser is adequate to ensure
# prompt data transmissions to the browser.
# The situation with non-notebook use is similar, but the http server is threaded,
# in order to serve glowcomm.html, jpg texture files, and font files, and the
# websocket is also threaded.
# In both the notebook and non-notebook cases output is buffered in baseObj.updates
# and sent as a block to the browser at render times.
老实说,我不认为vpython的模型是一个好的API模型(一方面,在普通的交互式shell中使用它很尴尬),但我想它是可行的