Repository: ManimCommunity/manim

Issue:
--enable_gui not working in Ubuntu 20.04+ (may affect other versions and distros as well)
## Description of bug / unexpected behavior
<!-- Add a clear and concise description of the problem you encountered. -->
Passing `--enable_gui` when using `--renderer=opengl`doesn't open the gui window for Ubuntu 20.04+ . `dearpygui` is installed and when trying to render the scene, no error message shows and only the opengl window is displayed.

## Expected behavior
<!-- Add a clear and concise description of what you expected to happen. -->
The gui window would display.

## How to reproduce the issue
<!-- Provide a piece of code illustrating the undesired behavior. -->
`manim -p example.py OpenGLShow --renderer=opengl --enable_gui`

<details><summary>Code for reproducing the problem</summary>

```py
Paste your code here.
```

</details>


## Additional media files
<!-- Paste in the files manim produced on rendering the code above. -->

<details><summary>Images/GIFs</summary>

<!-- PASTE MEDIA HERE -->

</details>


## Logs
<details><summary>Terminal output</summary>
<!-- Add "-v DEBUG" when calling manim to generate more detailed logs -->

```
PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR
```

<!-- Insert screenshots here (only when absolutely necessary, we prefer copy/pasted output!) -->

</details>


## System specifications

<details><summary>System Details</summary>

- OS (with version, e.g Windows 10 v2004 or macOS 10.15 (Catalina)): Ubuntu 20.04
- RAM: 16GB
- Python version (`python/py/python3 --version`): 3.8.10
- Installed modules (provide output from `pip list`):
```
Package                       Version
----------------------------- ------------
alabaster                     0.7.12
anyio                         3.2.1
apipkg                        1.5
appdirs                       1.4.4
argon2-cffi                   20.1.0
astroid                       2.6.2
async-generator               1.10
attrs                         21.2.0
Babel                         2.9.1
backcall                      0.2.0
beautifulsoup4                4.9.3
black                         20.8b1
bleach                        3.3.0
certifi                       2021.5.30
cffi                          1.14.5
cfgv                          3.3.0
chardet                       4.0.0
click                         8.0.1
click-default-group           1.2.2
cloup                         0.7.1
colorama                      0.4.4
colour                        0.1.5
commonmark                    0.9.1
coverage                      5.5
cycler                        0.10.0
dearpygui                     0.8.54
debugpy                       1.3.0
decorator                     5.0.9
defusedxml                    0.7.1
Deprecated                    1.2.12
distlib                       0.3.2
docutils                      0.17.1
entrypoints                   0.3
execnet                       1.9.0
filelock                      3.0.12
flake8                        3.9.2
flake8-bugbear                21.4.3
flake8-builtins               1.5.3
flake8-comprehensions         3.4.0
flake8-docstrings             1.6.0
flake8-logging-format         0.6.0
flake8-plugin-utils           1.3.1
flake8-pytest-style           1.4.1
flake8-rst-docstrings         0.0.14
furo                          2021.6.18b36
gitdb                         4.0.7
GitPython                     3.1.18
glcontext                     2.3.4
guzzle-sphinx-theme           0.7.11
identify                      2.2.10
idna                          3.2
imagesize                     1.2.0
iniconfig                     1.1.1
ipykernel                     6.0.1
ipython                       7.25.0
ipython-genutils              0.2.0
isort                         5.9.1
jedi                          0.18.0
Jinja2                        3.0.1
json5                         0.9.6
jsonschema                    3.2.0
jupyter-client                6.2.0
jupyter-core                  4.7.1
jupyter-server                1.9.0
jupyterlab                    3.0.16
jupyterlab-pygments           0.1.2
jupyterlab-server             2.6.0
kiwisolver                    1.3.1
lazy-object-proxy             1.6.0
manim                         0.8.0
ManimPango                    0.3.0
mapbox-earcut                 0.12.10
MarkupSafe                    2.0.1
matplotlib                    3.4.2
matplotlib-inline             0.1.2
mccabe                        0.6.1
mistune                       0.8.4
moderngl                      5.6.4
moderngl-window               2.4.0
mpmath                        1.2.1
multipledispatch              0.6.0
mypy-extensions               0.4.3
nbclassic                     0.3.1
nbclient                      0.5.3
nbconvert                     6.1.0
nbformat                      5.1.3
nest-asyncio                  1.5.1
networkx                      2.5
nodeenv                       1.6.0
notebook                      6.4.0
numpy                         1.21.0
packaging                     20.9
pandocfilters                 1.4.3
parso                         0.8.2
pathspec                      0.8.1
pexpect                       4.8.0
pickleshare                   0.7.5
Pillow                        8.2.0
pip                           21.0.1
pluggy                        0.13.1
pre-commit                    2.13.0
prometheus-client             0.11.0
prompt-toolkit                3.0.19
psutil                        5.8.0
ptyprocess                    0.7.0
py                            1.10.0
pycairo                       1.20.1
pycodestyle                   2.7.0
pycparser                     2.20
pydocstyle                    6.0.0
pydub                         0.25.1
pyflakes                      2.3.1
PyGithub                      1.55
pyglet                        1.5.18
Pygments                      2.9.0
PyJWT                         2.1.0
pylint                        2.9.3
PyNaCl                        1.4.0
pyparsing                     2.4.7
pyrr                          0.10.3
pyrsistent                    0.18.0
pytest                        6.2.4
pytest-cov                    2.12.1
pytest-forked                 1.3.0
pytest-xdist                  2.3.0
python-dateutil               2.8.1
pytz                          2021.1
PyYAML                        5.4.1
pyzmq                         22.1.0
recommonmark                  0.7.1
regex                         2021.7.1
requests                      2.15.1
requests-unixsocket           0.2.0
restructuredtext-lint         1.3.2
rich                          10.4.0
scipy                         1.6.1
screeninfo                    0.6.7
Send2Trash                    1.7.1
setuptools                    52.0.0
six                           1.16.0
smmap                         4.0.0
sniffio                       1.2.0
snowballstemmer               2.1.0
soupsieve                     2.2.1
Sphinx                        3.5.3
sphinx-copybutton             0.3.3
sphinxcontrib-applehelp       1.0.2
sphinxcontrib-devhelp         1.0.2
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.5
sphinxext-opengraph           0.4.2
terminado                     0.10.1
testpath                      0.5.0
toml                          0.10.2
tornado                       6.1
tqdm                          4.61.1
traitlets                     5.0.5
typed-ast                     1.4.3
typing-extensions             3.10.0.0
urllib3                       1.26.6
virtualenv                    20.4.7
watchdog                      2.1.3
wcwidth                       0.2.5
webencodings                  0.5.1
websocket-client              1.1.0
wheel                         0.36.2
wrapt                         1.12.1
```
</details>

<details><summary>LaTeX details</summary>

+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:
<!-- output of `tlmgr list --only-installed` for TeX Live or a screenshot of the Packages page for MikTeX -->
</details>

<details><summary>FFMPEG</summary>

Output of `ffmpeg -version`:

```
PASTE HERE
```
</details>

## Additional comments
<!-- Add further context that you think might be relevant for this issue here. -->



Discussion:
I'm on Ubuntu 21.04 and the GUI window doesn't appear to me as well. I've installed the opengl and gui stuff using `poetry install --extras "webgl_renderer jupyterlab gui"`. The gui window works on Windows OS though. 
I noticed the gui stopped working for me when I updated poetry dependencies, it seems that in #1808 dearpygui was upgraded to 0.8, but I think it the usage has changed from 0.6.x and so for me at least it is failing on `import dearpygui.core`, but works if I change it to `import dearpygui.dearpygui as dpg`
I can doubly confirm that reverting to version 0.6.415 for `dearpygui` fixed the issue.
Does it work on 0.8 if you change the import statement, or are those the steps you took to make it work on 0.6?
I created a draft PR,  I will test more later but seemed to be working with 0.8.x, if you have time can you try it on ubuntu @newell ?
@ryanmccauley211 I can confirm that your PR fixes the issue.
Works for me as well, thanks @ryanmccauley211!

Resolving patch:
diff --git a/manim/gui/gui.py b/manim/gui/gui.py
--- a/manim/gui/gui.py
+++ b/manim/gui/gui.py
@@ -1,24 +1,31 @@
 from pathlib import Path
 
 try:
-    import dearpygui.core
-    import dearpygui.demo
-    import dearpygui.simple
+    import dearpygui.dearpygui as dpg
+    from dearpygui.demo import show_demo
 
     dearpygui_imported = True
 except ImportError:
     dearpygui_imported = False
 
 
-from .. import config
+from .. import __version__, config
 from ..utils.module_ops import scene_classes_from_file
 
+if dearpygui_imported:
+    window = dpg.generate_uuid()
+
 
 def configure_pygui(renderer, widgets, update=True):
     if not dearpygui_imported:
         raise RuntimeError("Attempted to use DearPyGUI when it isn't imported.")
     if update:
-        dearpygui.core.delete_item("Manim GUI")
+        dpg.delete_item(window)
+    else:
+        dpg.setup_viewport()
+    dpg.set_viewport_title(title=f"Manim Community v{__version__}")
+    dpg.set_viewport_width(1015)
+    dpg.set_viewport_height(540)
 
     def rerun_callback(sender, data):
         renderer.scene.queue.put(("rerun_gui", [], {}))
@@ -27,33 +34,32 @@ def continue_callback(sender, data):
         renderer.scene.queue.put(("exit_gui", [], {}))
 
     def scene_selection_callback(sender, data):
-        config["scene_names"] = (dearpygui.core.get_value(sender),)
+        config["scene_names"] = (dpg.get_value(sender),)
         renderer.scene.queue.put(("rerun_gui", [], {}))
 
     scene_classes = scene_classes_from_file(Path(config["input_file"]), full_list=True)
     scene_names = [scene_class.__name__ for scene_class in scene_classes]
 
-    with dearpygui.simple.window(
-        "Manim GUI",
-        x_pos=config["gui_location"][0],
-        y_pos=config["gui_location"][1],
+    with dpg.window(
+        id=window,
+        label="Manim GUI",
+        pos=[config["gui_location"][0], config["gui_location"][1]],
         width=1000,
         height=500,
     ):
-        dearpygui.core.set_main_window_size(width=1015, height=540)
-        dearpygui.core.set_global_font_scale(2)
-        dearpygui.core.add_button("Rerun", callback=rerun_callback)
-        dearpygui.core.add_button("Continue", callback=continue_callback)
-        dearpygui.core.add_combo(
-            "Selected scene",
+        dpg.set_global_font_scale(2)
+        dpg.add_button(label="Rerun", callback=rerun_callback)
+        dpg.add_button(label="Continue", callback=continue_callback)
+        dpg.add_combo(
+            label="Selected scene",
             items=scene_names,
             callback=scene_selection_callback,
             default_value=config["scene_names"][0],
         )
-        dearpygui.core.add_separator()
+        dpg.add_separator()
         if len(widgets) != 0:
-            with dearpygui.simple.collapsing_header(
-                f"{config['scene_names'][0]} widgets", default_open=True
+            with dpg.collapsing_header(
+                label=f"{config['scene_names'][0]} widgets", default_open=True
             ):
                 for widget_config in widgets:
                     widget_config_copy = widget_config.copy()
@@ -62,11 +68,10 @@ def scene_selection_callback(sender, data):
                     if widget != "separator":
                         del widget_config_copy["name"]
                         del widget_config_copy["widget"]
-                        getattr(dearpygui.core, f"add_{widget}")(
-                            name, **widget_config_copy
-                        )
+                        getattr(dpg, f"add_{widget}")(name, **widget_config_copy)
                     else:
-                        dearpygui.core.add_separator()
-    # dearpygui.demo.show_demo()
+                        dpg.add_separator()
+    # show_demo()
+
     if not update:
-        dearpygui.core.start_dearpygui()
+        dpg.start_dearpygui()
diff --git a/manim/opengl/__init__.py b/manim/opengl/__init__.py
--- a/manim/opengl/__init__.py
+++ b/manim/opengl/__init__.py
@@ -1,5 +1,5 @@
 try:
-    from dearpygui import core as dpg
+    from dearpygui import dearpygui as dpg
 except ImportError:
     pass
 
diff --git a/manim/scene/scene.py b/manim/scene/scene.py
--- a/manim/scene/scene.py
+++ b/manim/scene/scene.py
@@ -16,7 +16,7 @@
 from queue import Queue
 
 try:
-    import dearpygui.core
+    import dearpygui.dearpygui as dpg
 
     dearpygui_imported = True
 except ImportError:
@@ -1045,7 +1045,7 @@ def get_embedded_method(method_name):
         keyboard_thread.start()
 
         if self.dearpygui_imported and config["enable_gui"]:
-            if not dearpygui.core.is_dearpygui_running():
+            if not dpg.is_dearpygui_running():
                 gui_thread = threading.Thread(
                     target=configure_pygui,
                     args=(self.renderer, self.widgets),
@@ -1131,7 +1131,7 @@ def interact(self, shell, keyboard_thread):
         file_observer.join()
 
         if self.dearpygui_imported and config["enable_gui"]:
-            dearpygui.core.stop_dearpygui()
+            dpg.stop_dearpygui()
 
         if self.renderer.window.is_closing:
             self.renderer.window.destroy()


Test patch: