コード例 #1
0
ファイル: dashboard.py プロジェクト: SpikingNeurons/toolcraft
 def build(self):
     self.primary_window.build()
     # primary window dpg_id
     _primary_window_dpg_id = self.primary_window.dpg_id
     # set the things for primary window
     dpg.set_primary_window(window=_primary_window_dpg_id, value=True)
     # todo: have to figure out theme, font etc.
     # themes.set_theme(theme="Dark Grey")
     # assets.Font.RobotoRegular.set(item_dpg_id=_ret, size=16)
     dpg.bind_item_theme(item=_primary_window_dpg_id, theme=asset.Theme.DARK.get())
コード例 #2
0
ファイル: editor.py プロジェクト: georgedimitriadis/Heron
def update_control_graph_buttons(is_graph_running):
    """
    Used to enable and disable (grey out) the Start Graph or the End Graph according to whether the Graph is running or
    not
    :param is_graph_running: Is the graph running bool
    :return: Nothing
    """
    with dpg.theme() as theme_active:
        with dpg.theme_component(0):
            dpg.add_theme_color(dpg.mvThemeCol_Button, [50, 50, 180, 255], category=dpg.mvThemeCat_Core)

    with dpg.theme() as theme_non_active:
        with dpg.theme_component(0):
            dpg.add_theme_color(dpg.mvThemeCol_Button, [150, 150, 150, 255], category=dpg.mvThemeCat_Core)

    if is_graph_running:
        dpg.configure_item(start_graph_button_id, enabled=False)
        dpg.bind_item_theme(start_graph_button_id, theme_non_active)
        dpg.configure_item(end_graph_button_id, enabled=True)
        dpg.bind_item_theme(end_graph_button_id, theme_active)
    else:
        dpg.configure_item(start_graph_button_id, enabled=True)
        dpg.bind_item_theme(start_graph_button_id, theme_active)
        dpg.configure_item(end_graph_button_id, enabled=False)
        dpg.bind_item_theme(end_graph_button_id, theme_non_active)
コード例 #3
0
ファイル: editor.py プロジェクト: georgedimitriadis/Heron
def create_node_selector_window():
    with dpg.window(label='Node Selector', pos=[10, 60], width=300, height=890) as node_selector:
        # Create the window of the Node selector

        node_tree = generate_node_tree()
        base_id = node_tree[0][0]
        base_name = node_tree[0][1]
        with dpg.tree_node(label=base_name, parent=node_selector, default_open=True, id=base_id, open_on_arrow=True):

            # Read what *_com files exist in the Heron/Operations dir and sub dirs and create the correct
            # tree_node widget
            for parent_id, parent, node_id, node in node_tree:
                with dpg.tree_node(label=node, parent=parent_id, default_open=True, id=node_id):
                    for op in operations_list:
                        if node == op.parent_dir:
                            colour = gu.choose_color_according_to_operations_type(node)
                            button = dpg.add_button(label=op.name, width=200, height=30, callback=on_add_node)
                            with dpg.theme() as theme_id:
                                with dpg.theme_component(0):
                                    dpg.add_theme_color(dpg.mvThemeCol_Button, colour, category=dpg.mvThemeCat_Core)
                                    dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 5, category=dpg.mvThemeCat_Core)

                            dpg.bind_item_theme(button, theme_id)
        return node_selector
コード例 #4
0

def cb_add_3d_coords():
    with dpg.table_row(parent=ID.table1):
        for n in dpg.get_value(ID.values3):
            dpg.add_text(label=str(n))


with dpg.theme(tag='__round'):
    with dpg.theme_component(dpg.mvButton):
        dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 10)
        dpg.add_theme_style(dpg.mvStyleVar_FramePadding, 30, 30)

with dpg.window(label='basic dpg app', tag='main'):
    with dpg.group(horizontal=False):
        dpg.add_3d_slider(tag=ID.values3,
                          scale=.3,
                          callback=lambda: print(dpg.get_value(ID.values3)))
        dpg.add_button(label='add coords', callback=cb_add_3d_coords)
        dpg.bind_item_theme(dpg.last_item(), '__round')

    with dpg.table(tag=ID.table1, source='src'):
        dpg.add_table_column(label='x')
        dpg.add_table_column(label='y')
        dpg.add_table_column(label='z')

dpg.set_primary_window('main', True)
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
コード例 #5
0
 def bind_theme(self, theme: asset.Theme):
     dpg.bind_item_theme(item=self.dpg_id, theme=theme.get())
コード例 #6
0
    def spawn_node_on_editor(self):
        self.context = zmq.Context()
        self.initialise_parameters_socket()

        with dpg.node(label=self.name,
                      parent=self.parent,
                      pos=[self.coordinates[0],
                           self.coordinates[1]]) as self.id:
            colour = choose_color_according_to_operations_type(
                self.operation.parent_dir)
            with dpg.theme() as self.theme_id:
                with dpg.theme_component(0):
                    dpg.add_theme_color(dpg.mvNodeCol_TitleBar,
                                        colour,
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_TitleBarSelected,
                                        colour,
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_TitleBarHovered,
                                        colour,
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundSelected,
                                        [120, 120, 120, 255],
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_NodeBackground,
                                        [70, 70, 70, 255],
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundHovered,
                                        [80, 80, 80, 255],
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_NodeOutline,
                                        [50, 50, 50, 255],
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_style(dpg.mvNodeStyleVar_NodeBorderThickness,
                                        x=4,
                                        category=dpg.mvThemeCat_Nodes)
            dpg.bind_item_theme(self.id, self.theme_id)

            # Loop through all the attributes defined in the operation (as seen in the *_com.py file) and put them on
            # the node
            same_line_widget_ids = []
            for i, attr in enumerate(self.operation.attributes):

                if self.operation.attribute_types[i] == 'Input':
                    attribute_type = dpg.mvNode_Attr_Input
                elif self.operation.attribute_types[i] == 'Output':
                    attribute_type = dpg.mvNode_Attr_Output
                elif self.operation.attribute_types[i] == 'Static':
                    attribute_type = dpg.mvNode_Attr_Static

                attribute_name = attr + '##{}##{}'.format(
                    self.operation.name, self.node_index)

                with dpg.node_attribute(label=attribute_name,
                                        parent=self.id,
                                        attribute_type=attribute_type):
                    if attribute_type == 1:
                        dpg.add_spacer()
                    dpg.add_text(label='##' + attr + ' Name{}##{}'.format(
                        self.operation.name, self.node_index),
                                 default_value=attr)

                    if 'Parameters' in attr:
                        for k, parameter in enumerate(
                                self.operation.parameters):
                            if self.operation.parameter_types[k] == 'int':
                                id = dpg.add_input_int(
                                    label='{}##{}'.format(
                                        parameter, attribute_name),
                                    default_value=self.node_parameters[k],
                                    callback=self.update_parameters,
                                    width=100,
                                    min_clamped=False,
                                    max_clamped=False,
                                    min_value=int(-1e8),
                                    max_value=int(1e8),
                                    on_enter=True)
                            elif self.operation.parameter_types[k] == 'str':
                                id = dpg.add_input_text(
                                    label='{}##{}'.format(
                                        parameter, attribute_name),
                                    default_value=self.node_parameters[k],
                                    callback=self.update_parameters,
                                    width=100,
                                    on_enter=True)
                            elif self.operation.parameter_types[k] == 'float':
                                id = dpg.add_input_float(
                                    label='{}##{}'.format(
                                        parameter, attribute_name),
                                    default_value=self.node_parameters[k],
                                    callback=self.update_parameters,
                                    width=100,
                                    min_clamped=False,
                                    max_clamped=False,
                                    min_value=-1e10,
                                    max_value=1e10,
                                    on_enter=True)
                            elif self.operation.parameter_types[k] == 'bool':
                                id = dpg.add_checkbox(
                                    label='{}##{}'.format(
                                        parameter, attribute_name),
                                    default_value=self.node_parameters[k],
                                    callback=self.update_parameters)
                            elif self.operation.parameter_types[k] == 'list':
                                default_value = self.node_parameters[k][0]
                                if type(self.node_parameters[k]) == str:
                                    default_value = self.node_parameters[k]
                                id = dpg.add_combo(
                                    label='{}##{}'.format(
                                        parameter, attribute_name),
                                    items=self.node_parameters_combos_items[k],
                                    default_value=default_value,
                                    callback=self.update_parameters,
                                    width=100)

                            self.parameter_inputs_ids[parameter] = id

                    dpg.add_spacer(label='##Spacing##' + attribute_name,
                                   indent=3)

            # Add the extra input button with its popup window for extra inputs like ssh and verbosity
            self.extra_input_window()