mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Add (optional) error sound for exceptions in Scene.embed
This commit is contained in:
parent
cba101995f
commit
71815fd7de
3 changed files with 15 additions and 1 deletions
|
@ -492,4 +492,5 @@ def get_configuration(args: Namespace) -> dict:
|
|||
"leave_progress_bars": args.leave_progress_bars,
|
||||
"show_animation_progress": args.show_animation_progress,
|
||||
"embed_exception_mode": custom_config["embed_exception_mode"],
|
||||
"embed_error_sound": custom_config["embed_error_sound"],
|
||||
}
|
||||
|
|
|
@ -43,3 +43,4 @@ camera_resolutions:
|
|||
default_resolution: "high"
|
||||
fps: 30
|
||||
embed_exception_mode: "Verbose"
|
||||
embed_error_sound: False
|
||||
|
|
|
@ -74,7 +74,8 @@ class Scene(object):
|
|||
preview: bool = True,
|
||||
presenter_mode: bool = False,
|
||||
show_animation_progress: bool = False,
|
||||
embed_exception_mode = "",
|
||||
embed_exception_mode: str = "",
|
||||
embed_error_sound: bool = False,
|
||||
):
|
||||
self.skip_animations = skip_animations
|
||||
self.always_update_mobjects = always_update_mobjects
|
||||
|
@ -85,6 +86,7 @@ class Scene(object):
|
|||
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.camera_config = {**self.default_camera_config, **camera_config}
|
||||
self.window_config = {**self.default_window_config, **window_config}
|
||||
|
@ -251,6 +253,16 @@ 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)
|
||||
os.system("printf '\a'")
|
||||
|
||||
shell.set_custom_exc((Exception,), custom_exc)
|
||||
|
||||
# Set desired exception mode
|
||||
shell.magic(f"xmode {self.embed_exception_mode}")
|
||||
|
||||
# Launch shell
|
||||
|
|
Loading…
Add table
Reference in a new issue