-1

first post on stackoverflow, apologies if this is not written correctly I am pretty new to Python and Very new to Manim. I am a big fan of 3b1b, and was using one of his files from gitlab as a baseline for my text animation (For Reference: https://github.com/3b1b/videos/blob/3dc2bc24006a6d032eb3e7502914492d6f24bcdc/_2016/eola/chapter0.py) I am just playing around and trying to get a text animation to run but I am getting an error and I cannot seem to find a solution to. I don't know if I am missing a Library or if I am just simply not understanding what the function is asking me to fix, below is my current code. (I am just trying to make my friends laugh so ignore the quote"

from manimlib.animation.creation import Write
from manimlib.animation.fading import FadeIn
from manimlib.constants import *
from manimlib.scene.scene import Scene
from manimlib.utils.rate_functions import linear
from manim import RED, GREEN, BLUE, PURPLE
from manim import *
from manimlib import *
from manimlib.mobject.svg.tex_mobject import *
from manimpango import *
from manimlib.mobject.svg.tex_mobject import *

class OpeningQuote(Scene):
    def construct(self):
        words= (
            """
            ``Every PooPoo time is PP time 
            but not every PP time is Poo Poo time :(``
            """,
           
        )
        words.set_width(FRAME_WIDTH-1)
        words.to_edge(UP)
        for mob in words.submobjects[48:49+13]:
            mob.set_color(PURPLE)
        author = ("--Taylor Woodard\\'e")
        author.set_color(GREEN)
        author.next_to(words, DOWN)

        self.play(FadeIn(words))
        self.wait(2)
        self.play(Write(author, run_time = 4))
        self.wait()  

Again, pretty new to python so I apologize if this my codes look chaotic

I tried adding new/different libraries from manim, I tried filling in the 'set_width' argument with something that was predefined (basically anything that would be autofilled) and I just don't know what I am missing

the error I am getting is: "AttributeError: 'tuple' object has no attribute 'set_width'"

Again, apologies if this post is rough. I will do better next time.

Anything will help. Please feel free to tear apart my code as well. I am willing to learn

Thanks!

Kache
  • 15,647
  • 12
  • 51
  • 79

1 Answers1

0

What's Happening

Interpreting FRAME_WIDTH to be an integer, a simplified example of the same issue would be:

FRAME_WIDTH = 5

words= (
        """
        ``Every PooPoo time is PP time 
        but not every PP time is Poo Poo time :(``
        """,
     
)
words.set_width(FRAME_WIDTH-1)

Simplifying further, because the content of the str doesn't matter to reproduce the error:

words = ("foo",)
words.set_width(2)

I can tell the words.set_width() line is the issue because with the above saved as the file, bar.py and running python bar.py, I see:

❯ python bar.py
Traceback (most recent call last):
  File "bar.py", line 2, in <module>
    words.set_width(2)
AttributeError: 'tuple' object has no attribute 'set_width'

Which says on line 2, set_width() is being called on a tuple-typed object, and tuples don't have a method set_width().

Either a different method should be called on the tuple, or set_width() should be called on a different type of object.

You'll notice in your linked example:

    def construct(self):
        words = OldTexText(
            """
            ``There is hardly any theory which is more elementary 
            than linear algebra, in spite of the fact that generations 
            of professors and textbook writers have obscured its 
            simplicity by preposterous calculations with matrices.''
            """, 
            organize_left_to_right = False
        )
        words.set_width(2*(FRAME_X_RADIUS-1))

words is set to an ToldTexText-typed object and set_width() called on it, which isn't what you're doing.

What You Should Do

To be frank, it looks like your goal is just a bit beyond your current skill level with Python & programming. For this particular issue, skills/knowledge in the following would have helped:

  • how to debug simple syntax errors and exceptions
  • types/classes and methods, i.e. the basics of Object-Oriented Programming
  • Python's built-in types like tuple

Notable keywords in bold should help when searching for relevant tutorials & other material.

Kache
  • 15,647
  • 12
  • 51
  • 79