Runtime
PySandbox includes a custom runtime module pysandbox.py
with a single a single function:
def display(obj, target, mime_type=None): ...
For convinence this is auto-imported into every codeblock via:
import display from pysandbox
You can pass in an ipython compatible object that exposes repr****_ or matplotlib.pyplot
.
import plt from matplotlib
...
display(plt, target=current_target())
where current_target
is a pre-defined convenience function:
def current_target(): return _pysandbox_target
which returns the target passed into exec
.
Here is a full example:
<div id="output"></div>
const sandbox = new PyMainThreadSandbox();await sandbox.init();await sandbox.exec("display('hello', current_target())", "output");