Skip to content

[BUG] manim-slides gets confused with multiple scenes #205

@ccoors

Description

@ccoors

Description

When using multiple scenes, manim-slides appears to get confused with slide-order and replaying animations.

Take the following example:

from manim import *
from manim_slides import Slide


class Part1(Slide):
    def construct(self):
        self.add(MarkupText("Part 1").shift(3 * UP))
        counter = DecimalNumber().shift(2 * UP)
        self.add(counter)
        square = Square(color=BLUE, fill_opacity=1)
        self.play(square.animate.shift(LEFT))
        self.next_slide()

        counter.set_value(1)
        self.play(square.animate.scale(0.3))
        self.next_slide()


class Part2(Slide):
    def construct(self):
        self.add(MarkupText("Part 2").shift(3 * UP))
        counter = DecimalNumber().shift(2 * UP)
        self.add(counter)
        square = Square(color=RED, fill_opacity=1)
        self.play(square.animate.shift(3 * RIGHT))
        counter.set_value(1)
        self.play(square.animate.set_color(GRAY))
        self.next_slide()

        counter.set_value(2)
        self.play(square.animate.scale(1.3))
        self.next_slide()

I am running these commands:

$ manim -qh bug.py Part1 Part2
$ manim-slides Part1 Part2

Steps to reproduce weird behavior

  1. Slideshow starts normally, blue square is shown moving left
  2. Press right arrow, Square shrinks. Immediately afterwards, Part2 starts (even though there is a self.next_slide() in the code that should pause)
  3. After the red square moved right and turned gray, press the left arrow key. Part1 starts from the beginning, not from animation 2
  4. Press the right arrow once, the blue square shrinks and only the second animation from the first section of Part2 is shown (not the square moving right, but only the square turning gray)

Additional weird behavior

Remove the first self.next_slide() from Part1, leaving only the one at the end. Press the left arrow key while Part2 plays and observe the following Traceback:

Traceback (most recent call last):
  File "/home/.../venv/lib/python3.11/site-packages/manim_slides/present.py", line 445, in run
    self.handle_key()
  File "/home/.../venv/lib/python3.11/site-packages/manim_slides/present.py", line 564, in handle_key
    self.current_presentation.load_last_slide()
  File "/home/.../venv/lib/python3.11/site-packages/manim_slides/present.py", line 275, in load_last_slide
    self.current_slide_index >= 0
AssertionError: Slides should be at list of a least two elements

Sorry if this issue is a bit confusing, but separating it into multiple issues would probably not be helping.

Version

manim-slides, version 4.14.0, used with Manim Community v0.17.3

Platform

Linux

Screenshots

No response

Additional information

Possibly related to #161?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpresentRelated to the main "present" feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions