def start(self): dpg.setup_registries() dpg.setup_viewport() dpg.set_viewport_title("Simple Data Flow") node_editor = NodeEditor() with dpg.window() as main_window: with dpg.menu_bar(): with dpg.menu(label="Operations"): dpg.add_menu_item(label="Reset", callback=lambda: dpg.delete_item(node_editor.uuid, children_only=True)) with dpg.menu(label="Plugins"): for plugin in self.plugins: dpg.add_menu_item(label=plugin[0], callback=plugin[1]) with dpg.group(horizontal=True) as group: # left panel with dpg.group(id=self.left_panel): self.data_set_container.submit(self.left_panel) self.modifier_container.submit(self.left_panel) # center panel node_editor.submit(group) # right panel with dpg.group(id=self.right_panel): self.inspector_container.submit(self.right_panel) self.tool_container.submit(self.right_panel) dpg.set_primary_window(main_window, True) dpg.start_dearpygui()
https://hub.fastgit.org/Pcothren/DearPyGui-Examples """ dpg.show_style_editor() def save_callback(sender, app_data, user_data): print(dpg) print("Save Clicked") for i in dpg.get_all_items(): print(i) print(sender, app_data, user_data, dpg.get_value(2)) print(sender, app_data, user_data, dpg.get_value(3)) print(sender, app_data, user_data, dpg.get_value(4)) print(sender, app_data, user_data, dpg.get_value(21)) with dpg.window(id=0, label="Example Window By LC", width=500, height=500): dpg.add_text(id=1, label="Hello world Hello LC", show_label=True) # label – 覆盖“name”作为标签。 # id – 用于以编程方式引用项目的唯一 id。如果标签未使用,这将是标签 text_input = dpg.add_input_text(id=2, label="MyInput") text_slider = dpg.add_slider_float(id=3, label="MySlider") text_input2 = dpg.add_input_text(id=4, label="name", default_value="LC") dpg.add_button(id=5, label="Save", callback=save_callback, user_data=text_input) dpg.setup_viewport() dpg.start_dearpygui()
def configure_pygui(renderer, widgets, update=True): if not dearpygui_imported: raise RuntimeError( "Attempted to use DearPyGUI when it isn't imported.") if update: 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", [], {})) def continue_callback(sender, data): renderer.scene.queue.put(("exit_gui", [], {})) def scene_selection_callback(sender, data): 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 dpg.window( id=window, label="Manim GUI", pos=[config["gui_location"][0], config["gui_location"][1]], width=1000, height=500, ): 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], ) dpg.add_separator() if len(widgets) != 0: 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() name = widget_config_copy["name"] widget = widget_config_copy["widget"] if widget != "separator": del widget_config_copy["name"] del widget_config_copy["widget"] getattr(dpg, f"add_{widget}")(name, **widget_config_copy) else: dpg.add_separator() if not update: dpg.start_dearpygui()