示例#1
0
def node_attribute(*args,
                   show: bool = True,
                   output: bool = False,
                   static: bool = False,
                   parent: str = "",
                   before: str = "",
                   shape: int = 1):
    """Wraps add_node_attribute() and automates calling end().

    Args:
        name: Unique name used to programmatically refer to the item. If label is unused this will be the label,
            anything after "##" that occurs in the name will not be shown on screen.
        **parent: Parent to add this item to. (runtime adding)
        **before: This item will be displayed before the specified item in the parent. (runtime adding)
        **show: sets if the item is shown or not window.
        **output: Set as output attribute
        **static: Set as static attribute

    Returns:
        None
    """
    try:
        yield internal_dpg.add_node_attribute(*args,
                                              show=show,
                                              parent=parent,
                                              before=before,
                                              output=output,
                                              static=static,
                                              shape=shape)

    finally:
        internal_dpg.end()
示例#2
0
    def create_node(self, node_type: str = "Root Prompt"):
        '''
        Creates a node
        '''
        node_name = "{}##{}".format(node_type, self.node_index)

        with simple.node(node_name):
            # Id num
            with simple.node_attribute("ID##{0}".format(self.node_index),
                                       static=True):
                core.add_text("ID: {}".format(self.node_index))

            # Input connection
            core.add_node_attribute("Input##{}".format(self.node_index))

            # Text input field
            with simple.node_attribute("TextBox##{}".format(self.node_index),
                                       static=True):
                core.add_input_text("##Text_{}".format(self.node_index),
                                    width=200,
                                    height=50,
                                    multiline=True)

            # Output connection
            core.add_node_attribute("Output##{}".format(self.node_index),
                                    output=True)

            # Checkbox for callback condition
            with simple.node_attribute("HasCallback##{}".format(
                    self.node_index),
                                       static=True):
                core.add_checkbox("Has Callback##{}".format(self.node_index))

            # Checkbox for end condition
            with simple.node_attribute("IsEnd##{}".format(self.node_index),
                                       static=True):
                core.add_checkbox("Is End##{}".format(self.node_index))

        self.nodes[self.node_index] = node_name

        if node_type == "Response":
            self.tree.add_response()
        else:
            self.tree.add_prompt()

        self.node_index += 1
示例#3
0
 def _setup_add_widget(self, dpg_args) -> None:
     dpgcore.add_node_attribute(self.id, **dpg_args)