Example #1
0
 def create_error_window(error_text, spacer):
     with dpg.window(label="Error Window", modal=True, show=True, id="modal_error_id",
                     no_title_bar=True, popup=True):
         dpg.add_text(error_text)
         dpg.add_separator()
         with dpg.group(horizontal=True):
             dpg.add_spacer(width=spacer)
             dpg.add_button(label="OK", width=75, callback=delete_error_popup_aliases)
Example #2
0
def _node_editor():
    dpg.add_separator(label='BOT')
    dpg.add_text('STRATEGY ALGORITHM')
    with dpg.node_editor(callback=_link_node, delink_callback=_delink_node, menubar=True, height=500) as node_editor_id:
        with dpg.menu_bar():
            with dpg.menu(label='New'):
                dpg.add_menu_item(label='dealer', callback=lambda: nodes.add_dealer(node_editor_id, exchange))
                dpg.add_menu_item(label='current price', callback=lambda: nodes.add_current_price(node_editor_id))
                dpg.add_menu_item(label='symbol', callback=lambda: nodes.add_symbol(node_editor_id))
                dpg.add_menu_item(label='historical period', callback=lambda: nodes.add_history(node_editor_id))
                dpg.add_menu_item(label='rolling mean', callback=lambda: nodes.add_rolling_mean(node_editor_id))
                dpg.add_menu_item(label='distance', callback=lambda: nodes.add_distance(node_editor_id))
                dpg.add_menu_item(label='rlines', callback=lambda: nodes.add_rlines(node_editor_id))

        nodes.add_symbol(node_editor_id)
        nodes.add_current_price(node_editor_id)
        nodes.add_history(node_editor_id)
        nodes.add_rlines(node_editor_id)
Example #3
0
    def add_row(self, row_content: list[any]):
        self.ssh_info[row_content[1]] = {}
        with dpg.table_row(parent=self.id):
            for i, item in enumerate(row_content):
                item_name = f"##{self.name}_{self.row}_{self.column}"

                if i > 1:
                    self.ssh_info[row_content[1]][self.header[i]] = item
                if type(item) is str:
                    self.rows_ids[item_name] = dpg.add_input_text(
                        label=item_name,
                        default_value=item,
                        width=-1,
                        callback=self.on_edit)
                if type(item) is int:
                    self.rows_ids[item_name] = dpg.add_input_int(
                        label=item_name,
                        default_value=item,
                        width=-1,
                        step=0,
                        callback=self.on_edit)
                if type(item) is float:
                    self.rows_ids[item_name] = dpg.add_input_float(
                        label=item_name,
                        default_value=item,
                        width=-1,
                        step=0,
                        callback=self.on_edit)
                if type(item) is bool:
                    self.rows_ids[item_name] = dpg.add_checkbox(
                        label=item_name, default_value=False)
                if i == 1:
                    dpg.configure_item(self.rows_ids[item_name], enabled=False)
                if i == 6:
                    with dpg.tooltip(self.rows_ids[item_name]):
                        dpg.add_text(
                            "If the password is 'None' for the local machine\'s IP then the \n"
                            'local machine does not need to run an SSH server and the \n'
                            'communication between computers happens through normal sockets. \n'
                            'If there is a password other than "None" then Heron assumes an \n'
                            'SSH server is running on the local machine and all data and \n'
                            'parameters are passed through SSH tunnels.\nWARNING! '
                            'The SSH tunneling is slow and results in constant dropping of\n'
                            'data packets!')
                self.column += 1

            with dpg.table_row(parent=self.id):
                sep_name = f"##{self.name}_{self.row}_sep"
                self.rows_ids[sep_name] = dpg.add_separator(label=sep_name)

        self.num_of_rows += 1
        self.row += 1
        self.column = 0
Example #4
0
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()
Example #5
0
 def add_header(self, header: list[str]):
     dpg.add_separator(parent=self.parent_id)
     with dpg.table(header_row=True) as self.id:
         for item in header:
             self.column_ids.append(dpg.add_table_column(label=item))
Example #6
0
 def __setup_add_widget__(self, dpg_args) -> None:
     dpgcore.add_separator(name=self.id, **dpg_args)

def update_image(sender, app_data, user_data):
    image, controls = user_data
    kwargs = {}
    for k, v in controls.items():
        kwargs[k] = dpg.get_value(v)
    dpg.configure_item(image, **kwargs)


with dpg.window(label="Main"):
    dpg.add_text(
        "This is an example of a image being added to a drawlist and updated",
        bullet=True)
    dpg.add_spacing(count=5)
    dpg.add_separator()
    dpg.add_spacing()
    with dpg.group() as control_group:
        pmin = dpg.add_slider_intx(label="pmin",
                                   default_value=[0, 125],
                                   max_value=500,
                                   size=2)
        pmax = dpg.add_slider_intx(label="pmax",
                                   default_value=[416, 509],
                                   max_value=500,
                                   size=2)
        uv_min = dpg.add_slider_floatx(label="uv_min",
                                       default_value=[0, 0],
                                       max_value=3,
                                       min_value=-3,
                                       size=2)