mirror of
https://github.com/3b1b/manim.git
synced 2025-09-19 04:41:56 +00:00
Reduce the need to type 'self.' so much when embedding into a scene.
This commit is contained in:
parent
20b787223b
commit
e08784400a
1 changed files with 7 additions and 3 deletions
|
@ -118,9 +118,13 @@ class Scene(object):
|
||||||
shell = InteractiveShellEmbed()
|
shell = InteractiveShellEmbed()
|
||||||
# Have the frame update after each command
|
# Have the frame update after each command
|
||||||
shell.events.register('post_run_cell', lambda *a, **kw: self.update_frame())
|
shell.events.register('post_run_cell', lambda *a, **kw: self.update_frame())
|
||||||
# Stack depth of 2 means the shell will use
|
# Use the locals of the caller as the local namespace
|
||||||
# the namespace of the caller, not this method
|
# once embeded, and add a few custom shortcuts
|
||||||
shell(stack_depth=2)
|
local_ns = inspect.currentframe().f_back.f_locals
|
||||||
|
local_ns["touch"] = self.interact
|
||||||
|
for term in ("play", "add", "remove", "clear"):
|
||||||
|
local_ns[term] = getattr(self, term)
|
||||||
|
shell(local_ns=local_ns, stack_depth=2)
|
||||||
# End scene when exiting an embed.
|
# End scene when exiting an embed.
|
||||||
raise EndSceneEarlyException()
|
raise EndSceneEarlyException()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue