Skip to content

Commit 16a5042

Browse files
author
Oliver Strait
committed
Custom api for DearPyGui to process and fetch
Scene classes
1 parent f1fefc4 commit 16a5042

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

manim/scene/scene.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import random
1616
import threading
1717
import time
18-
from pathlib import Path
1918
from queue import Queue
2019

2120
import srt
@@ -54,7 +53,7 @@
5453
from ..utils.family_ops import restructure_list_to_exclude_certain_family_members
5554
from ..utils.file_ops import open_media_file
5655
from ..utils.iterables import list_difference_update, list_update
57-
from ..utils.module_ops import scene_classes_from_file
56+
from ..utils.module_ops import scene_classes_for_gui
5857

5958
if TYPE_CHECKING:
6059
from collections.abc import Iterable, Sequence
@@ -1570,9 +1569,7 @@ def scene_selection_callback(sender: Any, data: Any) -> None:
15701569
config["scene_names"] = (dpg.get_value(sender),)
15711570
self.queue.put(("rerun_gui", [], {}))
15721571

1573-
scene_classes = scene_classes_from_file(
1574-
Path(config["input_file"]), full_list=True
1575-
) # type: ignore[call-overload]
1572+
scene_classes = scene_classes_for_gui(config.input_file, type(self))
15761573
scene_names = [scene_class.__name__ for scene_class in scene_classes]
15771574

15781575
with dpg.window(

manim/utils/module_ops.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,9 @@ def is_child_scene(obj: Any) -> bool:
8282
if len(classes) == 0:
8383
raise ValueError(f"Could not found any classes of type {class_type.__name__}")
8484
return classes
85+
86+
87+
def scene_classes_for_gui(path: str, class_type: type[T]) -> list[type[T]]:
88+
"""Specified interface of dearpyGUI to fetch Scene-class instances"""
89+
module = module_from_file(Path(path))
90+
return search_classes_from_module(module, class_type)

0 commit comments

Comments
 (0)