mirror of
https://github.com/3b1b/manim.git
synced 2025-09-18 21:21:59 +00:00
Flash around border on exceptions in Scene.embed
This commit is contained in:
parent
71815fd7de
commit
ba68505c18
1 changed files with 13 additions and 7 deletions
|
@ -16,15 +16,18 @@ import numpy as np
|
|||
from tqdm import tqdm as ProgressDisplay
|
||||
|
||||
from manimlib.animation.animation import prepare_animation
|
||||
from manimlib.animation.fading import VFadeInThenOut
|
||||
from manimlib.camera.camera import Camera
|
||||
from manimlib.config import get_module
|
||||
from manimlib.constants import ARROW_SYMBOLS
|
||||
from manimlib.constants import DEFAULT_WAIT_TIME
|
||||
from manimlib.constants import COMMAND_MODIFIER
|
||||
from manimlib.constants import SHIFT_MODIFIER
|
||||
from manimlib.constants import RED
|
||||
from manimlib.event_handler import EVENT_DISPATCHER
|
||||
from manimlib.event_handler.event_type import EventType
|
||||
from manimlib.logger import log
|
||||
from manimlib.mobject.frame import FullScreenRectangle
|
||||
from manimlib.mobject.mobject import _AnimationBuilder
|
||||
from manimlib.mobject.mobject import Group
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
|
@ -34,7 +37,6 @@ from manimlib.mobject.types.vectorized_mobject import VMobject
|
|||
from manimlib.scene.scene_file_writer import SceneFileWriter
|
||||
from manimlib.utils.family_ops import extract_mobject_family_members
|
||||
from manimlib.utils.family_ops import recursive_mobject_remove
|
||||
from manimlib.utils.iterables import list_difference_update
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
|
@ -253,14 +255,18 @@ class Scene(object):
|
|||
|
||||
shell.events.register("post_run_cell", post_cell_func)
|
||||
|
||||
if self.embed_error_sound:
|
||||
# Play sound after any Exceptions
|
||||
def custom_exc(shell, etype, evalue, tb, tb_offset=None):
|
||||
# still show the error don't just swallow it
|
||||
shell.showtraceback((etype, evalue, tb), tb_offset=tb_offset)
|
||||
# Flash border, and potentially play sound, on exceptions
|
||||
def custom_exc(shell, etype, evalue, tb, tb_offset=None):
|
||||
# still show the error don't just swallow it
|
||||
shell.showtraceback((etype, evalue, tb), tb_offset=tb_offset)
|
||||
if self.embed_error_sound:
|
||||
os.system("printf '\a'")
|
||||
self.play(VFadeInThenOut(
|
||||
FullScreenRectangle().set_stroke(RED, 30).set_fill(opacity=0),
|
||||
run_time=0.5,
|
||||
))
|
||||
|
||||
shell.set_custom_exc((Exception,), custom_exc)
|
||||
shell.set_custom_exc((Exception,), custom_exc)
|
||||
|
||||
# Set desired exception mode
|
||||
shell.magic(f"xmode {self.embed_exception_mode}")
|
||||
|
|
Loading…
Add table
Reference in a new issue