mirror of
https://github.com/3b1b/manim.git
synced 2025-08-03 04:04:36 +08:00
Move embed configuration out of Scene, and get rid of error sound option
This commit is contained in:
@ -320,8 +320,6 @@ def get_scene_config(args: Namespace) -> dict:
|
||||
"presenter_mode": args.presenter_mode,
|
||||
"leave_progress_bars": args.leave_progress_bars,
|
||||
"show_animation_progress": args.show_animation_progress,
|
||||
"embed_exception_mode": global_config["embed_exception_mode"],
|
||||
"embed_error_sound": global_config["embed_error_sound"],
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,6 +57,8 @@ style:
|
||||
tex_template: "default"
|
||||
font: "Consolas"
|
||||
text_alignment: "LEFT"
|
||||
embed:
|
||||
exception_mode: "Verbose"
|
||||
resolution_options:
|
||||
# When the user passes in -l, -m, --hd or --uhd, these are the corresponding
|
||||
# resolutions
|
||||
@ -65,6 +67,4 @@ resolution_options:
|
||||
high: (1920, 1080)
|
||||
4k: (3840, 2160)
|
||||
universal_import_line: "from manimlib import *"
|
||||
embed_exception_mode: "Verbose"
|
||||
embed_error_sound: False
|
||||
ignore_manimlib_modules_on_reload: True
|
||||
|
@ -79,8 +79,6 @@ class Scene(object):
|
||||
reload_manager: Optional[ReloadManager] = None,
|
||||
presenter_mode: bool = False,
|
||||
show_animation_progress: bool = False,
|
||||
embed_exception_mode: str = "",
|
||||
embed_error_sound: bool = False,
|
||||
):
|
||||
self.skip_animations = skip_animations
|
||||
self.always_update_mobjects = always_update_mobjects
|
||||
@ -89,8 +87,6 @@ class Scene(object):
|
||||
self.leave_progress_bars = leave_progress_bars
|
||||
self.presenter_mode = presenter_mode
|
||||
self.show_animation_progress = show_animation_progress
|
||||
self.embed_exception_mode = embed_exception_mode
|
||||
self.embed_error_sound = embed_error_sound
|
||||
self.reload_manager = reload_manager
|
||||
|
||||
self.camera_config = {**self.default_camera_config, **camera_config}
|
||||
|
@ -1,11 +1,13 @@
|
||||
import inspect
|
||||
import pyperclip
|
||||
import re
|
||||
import os
|
||||
|
||||
from IPython.terminal import pt_inputhooks
|
||||
from IPython.terminal.embed import InteractiveShellEmbed
|
||||
|
||||
from manimlib.animation.fading import VFadeInThenOut
|
||||
from manimlib.config import get_global_config
|
||||
from manimlib.constants import RED
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.mobject.frame import FullScreenRectangle
|
||||
@ -38,11 +40,12 @@ def get_ipython_shell_for_embedded_scene(scene):
|
||||
module = ModuleLoader.get_module(caller_frame.f_globals["__file__"])
|
||||
module.__dict__.update(caller_frame.f_locals)
|
||||
module.__dict__.update(get_shortcuts(scene))
|
||||
exception_mode = get_global_config()["embed"]["exception_mode"]
|
||||
|
||||
return InteractiveShellEmbed(
|
||||
user_module=module,
|
||||
display_banner=False,
|
||||
xmode=scene.embed_exception_mode
|
||||
xmode=exception_mode
|
||||
)
|
||||
|
||||
|
||||
@ -94,8 +97,6 @@ def ensure_flash_on_error(shell, scene):
|
||||
def custom_exc(shell, etype, evalue, tb, tb_offset=None):
|
||||
# Show the error don't just swallow it
|
||||
shell.showtraceback((etype, evalue, tb), tb_offset=tb_offset)
|
||||
if scene.embed_error_sound:
|
||||
os.system("printf '\a'")
|
||||
rect = FullScreenRectangle().set_stroke(RED, 30).set_fill(opacity=0)
|
||||
rect.fix_in_frame()
|
||||
scene.play(VFadeInThenOut(rect, run_time=0.5))
|
||||
|
Reference in New Issue
Block a user