Python Sandbox lets you create graph images and math animation outputs from Python code, then save or insert the generated files into the editor.
Open it from Menu Sidebar > Python Sandbox.
- Matplotlib graphs
- Data visualizations
- Transparent PNG chart assets
- Manim math animations
- Educational visual elements for explainer videos
- Open a project.
- Open Python Sandbox from the menu sidebar.
- Choose Python Script or Manim Scene.
- Write code in the editable code panel.
- Click Run.
- Preview the generated output.
- Use Save to Assets or Insert.
Generated files are detected automatically when they are saved inside the provided out folder.
Released builds include a bundled Python Sandbox runtime with the required packages already installed: NumPy, Matplotlib, Pillow, SciPy, ImageIO, ImageIO FFmpeg support, and Manim. Users should not need to install these packages on their computer.
For local development or recovery, the app can still create a local repair sandbox in the app data folder when a bundled runtime is not available. Release builds should prepare the bundled runtime before packaging:
npm run prepare-python-sandboxThen package the app normally:
npm run packageThe sandbox preloads common libraries and variables. You should use these directly instead of writing import lines.
Available names include:
np
plt
animation
math
random
statistics
Path
out
WIDTH
HEIGHT
FPSFor Manim scenes, common Manim names are also preloaded when Manim is installed.
Do not write import lines in the editable code area.
Blocked examples:
import numpy as np
from manim import *The sandbox already provides the supported libraries. If an import line is present, Run will be disabled or rejected until you remove it.
x = np.linspace(-5, 5, 300)
y = x ** 2
plt.figure(figsize=(10, 5.625), dpi=160)
plt.plot(x, y, color="#8b5cf6", linewidth=4)
plt.grid(True, alpha=0.25)
plt.tight_layout()
plt.savefig(os.path.join(out, "parabola.png"), transparent=True)Use the scene class name shown in the Scene class field.
class GeneratedScene(Scene):
def construct(self):
title = Text("Huber Loss", font_size=48)
formula = MathTex(r"L_\delta(a)")
formula.next_to(title, DOWN, buff=0.5)
self.play(Write(title))
self.play(Write(formula))
self.wait(1)- Save outputs inside
out. - Use clear filenames such as
loss_curve.pngorgradient_descent.mp4. - Use transparent backgrounds for overlays when possible.
- Match the project aspect ratio with
WIDTH,HEIGHT, andFPS. - For graphs, use large figure size and high DPI for sharp exports.
- For Manim, keep scene class names simple and match the selected class field.
- Use Insert when you want the generated file placed directly on the current scene.
- Use Save to Assets when you want to keep the generated file for later.
The sandbox blocks import statements, package installation attempts, subprocess calls, and dynamic execution helpers such as eval and exec. This keeps the feature focused on creating editor assets with the supported preloaded tools.