-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Move configure_pygui
into a Scene
method and remove manim.gui
#4314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent change, thank you very much!
Left one question/suggestion that would cause a bit more work; we can just merge the current version as is if you don't think that this would be a good idea.
@@ -25,6 +26,8 @@ | |||
import dearpygui.dearpygui as dpg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about moving the dearpygui import down and into the scene __init__
to get rid of the weird dearpygui_imported
variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although that variable is weird, I believe that this import is better placed where it is right now. The dpg
module is used in .interactive_embed()
, .interact()
and the new ._configure_pygui()
. If we imported it inside __init__
, it would probably have to be stored as a Scene
attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I remembered a related discussion on Discord where I mentioned that it would probably be good to have a reference to dpg
from Scene
:
It would be nice to have an enum of all possible widgets
After giving it some thoughts, I believe that it's not intuitive to append a dictionary to
Scene.widgets
if you wanna add a widget and it's a bit prone to errors
There could be a dedicated method
Scene.add_gui_widget()
, but you still get no type hints for the kwargs
One could make one Scene method for each of the functions of Dear PyGui which adds a widget... but, in that case, it's much more straightforward to simply get a reference to Dear PyGui and directly use its functions instead
In my opinion, this requires a larger refactor which should be done in a subsequent PR...
Overview: What does this pull request change?
I took the
manim.gui.gui.configure_pygui
function, which is used inScene.interactive_embed()
, and transformed it into aScene
method. Since that function was the only thing inmanim.gui
, I deleted this module as well.Motivation and Explanation: Why and how do your changes improve the library?
configure_pygui
was only used byScene.interactive_embed()
.configure_pygui
only accesses the scene referenced by the renderer, so why not just pass the scene itself instead...?Scene.interactive_embed()
is the only code which callsconfigure_pygui
and it passes theScene.widgets
to it, so, again, the reference to the scene is enough.configure_pygui
also accesses theScene.queue
of actions to do duringScene.interact()
. ThisScene
is the referenced by the passed renderer... so, again, just pass the scene instead.dearpygui
is imported, in which casedearpygui_import = True
. Otherwise,dearpygui_import = False
. This exact same thing also already happens inmanim.scene.scene
.Because of the reasons above, I believe that this belongs better as a method of
Scene
. No need to pass a renderer (or scene), nor a list of widgets, becauseself
is aScene
which already has thewidgets
attribute, as well as thequeue
.Links to added or changed documentation pages
Further Information and Comments
Reviewer Checklist