-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Description
Description of bug / unexpected behavior
Below error is displayed when we render a Code mobject using opengl renderer. The same code works as expected when we use the cairo renderer.
Error:
TypeError: Only values of type VMobject can be added as
submobjects of Code, but the value Paragraph of 1
submobjects (at index 0) is of type Paragraph.
Expected behavior
The Code Mobject should work with the new OpenGL renderer
How to reproduce the issue
Copy below code in testing.py file.
Code for reproducing the problem
from manim import *
class CodeFromString(Scene):
def construct(self):
code = "import this"
rendered_code = Code(
code_string=code,
language="python",
background="window",
background_config={"stroke_color": "maroon"},
)
self.add(rendered_code)Now, run the code using opengl renderer.
manim testing.py -p --renderer=openglIt throws error with opengl. But, if we use cairo, it works as expected without error.
manim testing.py -p --renderer=cairoAdditional media files
Images/GIFs
Logs
Terminal output
Manim Community v0.19.0
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/vinodpandey/Projects/video/venv/lib/python3.10/site-packages/manim/cli/rend │
│ er/commands.py:107 in render │
│ │
│ 104 │ │ │ │ for SceneClass in scene_classes_from_file(file): │
│ 105 │ │ │ │ │ with tempconfig({}): │
│ 106 │ │ │ │ │ │ scene = SceneClass(renderer) │
│ ❱ 107 │ │ │ │ │ │ rerun = scene.render() │
│ 108 │ │ │ │ │ if rerun or config["write_all"]: │
│ 109 │ │ │ │ │ │ renderer.num_plays = 0 │
│ 110 │ │ │ │ │ │ continue │
│ │
│ /Users/vinodpandey/Projects/video/venv/lib/python3.10/site-packages/manim/scene/sc │
│ ene.py:237 in render │
│ │
│ 234 │ │ """ │
│ 235 │ │ self.setup() │
│ 236 │ │ try: │
│ ❱ 237 │ │ │ self.construct() │
│ 238 │ │ except EndSceneEarlyException: │
│ 239 │ │ │ pass │
│ 240 │ │ except RerunSceneException: │
│ │
│ /Users/vinodpandey/Projects/video/testing.py:7 in construct │
│ │
│ 4 class CodeFromString(Scene): │
│ 5 │ def construct(self): │
│ 6 │ │ code = "import this" │
│ ❱ 7 │ │ rendered_code = Code( │
│ 8 │ │ │ code_string=code, │
│ 9 │ │ │ language="python", │
│ 10 │ │ │ background="window", │
│ │
│ /Users/vinodpandey/Projects/video/venv/lib/python3.10/site-packages/manim/mobject/ │
│ text/code_mobject.py:225 in __init__ │
│ │
│ 222 │ │ │ self.line_numbers.next_to(self.code_lines, direction=LEFT).align_to( │
│ 223 │ │ │ │ self.code_lines, UP │
│ 224 │ │ │ ) │
│ ❱ 225 │ │ │ self.add(self.line_numbers) │
│ 226 │ │ │
│ 227 │ │ self.add(self.code_lines) │
│ 228 │
│ │
│ /Users/vinodpandey/Projects/video/venv/lib/python3.10/site-packages/manim/mobject/ │
│ mobject.py:504 in add │
│ │
│ 501 │ │ │ [child] │
│ 502 │ │ │
│ 503 │ │ """ │
│ ❱ 504 │ │ self._assert_valid_submobjects(mobjects) │
│ 505 │ │ unique_mobjects = remove_list_redundancies(mobjects) │
│ 506 │ │ if len(mobjects) != len(unique_mobjects): │
│ 507 │ │ │ logger.warning( │
│ │
│ /Users/vinodpandey/Projects/video/venv/lib/python3.10/site-packages/manim/mobject/ │
│ types/vectorized_mobject.py:174 in _assert_valid_submobjects │
│ │
│ 171 │ │ │ self.stroke_color = ManimColor.parse(stroke_color) │
│ 172 │ │
│ 173 │ def _assert_valid_submobjects(self, submobjects: Iterable[VMobject]) -> Self: │
│ ❱ 174 │ │ return self._assert_valid_submobjects_internal(submobjects, VMobject) │
│ 175 │ │
│ 176 │ # OpenGL compatibility │
│ 177 │ @property │
│ │
│ /Users/vinodpandey/Projects/video/venv/lib/python3.10/site-packages/manim/mobject/ │
│ mobject.py:170 in _assert_valid_submobjects_internal │
│ │
│ 167 │ │ │ │ │ error_message += ( │
│ 168 │ │ │ │ │ │ " You can try adding this value into a Group instead." │
│ 169 │ │ │ │ │ ) │
│ ❱ 170 │ │ │ │ raise TypeError(error_message) │
│ 171 │ │ │ if submob is self: │
│ 172 │ │ │ │ raise ValueError( │
│ 173 │ │ │ │ │ f"Cannot add {type(self).__name__} as a submobject of " │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: Only values of type VMobject can be added as submobjects of Code, but the value Paragraph of 1 submobjects (at index 0) is of type
Paragraph.
System specifications
System Details
- OS macOS 10.15:
- RAM: 32GB
- Python version (
python/py/python3 --version): Python 3.10.12 - Installed modules (provide output from
pip list):
Package Version Editable project location
---------------------- ----------- -----------------------------------------------
asttokens 3.0.0
av 13.1.0
beautifulsoup4 4.13.1
click 8.1.8
cloup 3.0.5
Cython 3.0.11
decorator 5.1.1
exceptiongroup 1.2.2
executing 2.2.0
glcontext 3.0.0
ipython 8.32.0
isosurfaces 0.1.2
jedi 0.19.2
manim 0.19.0
ManimPango 0.6.0
mapbox_earcut 1.0.3
markdown-it-py 3.0.0
matplotlib-inline 0.1.7
mdurl 0.1.2
moderngl 5.12.0
moderngl-window 3.1.1
networkx 3.4.2
numpy 2.2.2
parso 0.8.4
pexpect 4.9.0
pillow 11.1.0
pip 23.0.1
prompt_toolkit 3.0.50
ptyprocess 0.7.0
pure_eval 0.2.3
pycairo 1.27.0
pydub 0.25.1
pyglet 2.1.2
PyGLM 2.7.3
Pygments 2.19.1
pyobjc-core 11.0
pyobjc-framework-Cocoa 11.0
pyperclip 1.9.0
rich 13.9.4
scipy 1.15.1
screeninfo 0.8.1
setuptools 65.5.0
skia-pathops 0.8.0.post2
soupsieve 2.6
srt 3.5.3
stack-data 0.6.3
svgelements 1.9.6
tqdm 4.67.1
traitlets 5.14.3
typing_extensions 4.12.2
watchdog 6.0.0
wcwidth 0.2.13
LaTeX details
- LaTeX distribution (e.g. TeX Live 2020):
- Installed LaTeX packages:
Additional comments
Metadata
Metadata
Assignees
Labels
No labels