Esempio n. 1
0
def disable_item(item: Union[int, str]):
    """Disables the item.

    Args:
        **item: Item to disable.

    Returns:
        None
    """
    internal_dpg.configure_item(item, enabled=False)
Esempio n. 2
0
def enable_item(item: Union[int, str]):
    """Enables the item.

    Args:
        **item: Item to enable.

    Returns:
        None
    """
    internal_dpg.configure_item(item, enabled=True)
Esempio n. 3
0
def show_item(item: Union[int, str]):
    """Shows the item.

    Args:
        item: Item to show.

    Returns:
        None
    """
    internal_dpg.configure_item(item, show=True)
Esempio n. 4
0
 def __setattr__(self, key, value):
     # this might not always work especially when key is custom ...
     # in that case catch exception and figure out how to handle
     if self.is_built:
         # The default behaviour is to update configure the dpg item but
         # note that Form is not a typical Widget and hence we have no need for
         # "`internal_dpg.configure_item` ...",
         if not isinstance(self, Form):
             internal_dpg.configure_item(self.dpg_id, **{key: value})
     return super().__setattr__(key, value)
Esempio n. 5
0
def set_item_source(item: Union[int, str], source: Union[int, str]):
    """Sets the item's value, to the source's value. Widget's value will now be "linked" to source's value.

    Args:
        item: Item to me linked.
        source: Source to link to.

    Returns:
        None
    """
    internal_dpg.configure_item(item, source=source)
Esempio n. 6
0
def set_item_payload_type(item: Union[int, str], payload_type: str):
    """Sets the item's payload type.

    Args:
        item: Item the Height will be applied to.
        height: Height to be applied.

    Returns:
        None
    """
    internal_dpg.configure_item(item, payload_type=str)
Esempio n. 7
0
def set_item_pos(item: Union[int, str], pos: List[float]):
    """Sets the item's position.

    Args:
        item: Item the absolute position will be applied to.
        pos: X and Y positions relative to parent of the item.

    Returns:
        None
    """
    internal_dpg.configure_item(item, pos=pos)
Esempio n. 8
0
def set_item_width(item: Union[int, str], width: int):
    """Sets the item's width.

    Args:
        item: Item the Width will be applied to.
        width: Width to be applied.

    Returns:
        None
    """
    internal_dpg.configure_item(item, width=width)
Esempio n. 9
0
def set_item_label(item: Union[int, str], label: str):
    """Sets the item's displayed label, anything after the characters "##" in the name will not be shown.

    Args:
        item: Item label will be applied to.
        label: Displayed name to be applied.

    Returns:
        None
    """
    internal_dpg.configure_item(item, label=label)
Esempio n. 10
0
def set_item_drop_callback(item: Union[int, str], callback: Callable):
    """Sets the item's drop callack.

    Args:
        item: Item the callback will be applied to.
        callback: Callback to be applied.

    Returns:
        None
    """
    internal_dpg.configure_item(item, drop_callback=callback)
Esempio n. 11
0
def untrack_item(item: Union[int, str]):
    """Track item in scroll region.

    Args:
        item: Item the callback will be applied to.
        callback: Callback to be applied.

    Returns:
        None
    """
    internal_dpg.configure_item(item, tracked=False)
Esempio n. 12
0
def set_item_user_data(item: Union[int, str], user_data: Any):
    """Sets the item's callack_data to any python object.

    Args:
        item: Item the callback will be applied to.
        user_data: Callback_data to be applied.

    Returns:
        None
    """
    internal_dpg.configure_item(item, user_data=user_data)
Esempio n. 13
0
def set_item_track_offset(item: Union[int, str], offset: float):
    """Sets the item's track offset.

    Args:
        item: Item the Height will be applied to.
        height: Height to be applied.

    Returns:
        None
    """
    internal_dpg.configure_item(item, track_offset=offset)
Esempio n. 14
0
def set_item_indent(item: Union[int, str], indent: int):
    """Sets the item's indent.

    Args:
        item: Item the Height will be applied to.
        height: Height to be applied.

    Returns:
        None
    """
    internal_dpg.configure_item(item, indent=indent)
Esempio n. 15
0
def hide_item(item: Union[int, str], *, children_only: bool = False):
    """Hides the item.

    Args:
        **item: Item to hide.

    Returns:
        None
    """
    if children_only:
        children = get_item_children(item)
        for child in children:
            internal_dpg.configure_item(child, show=False)
    else:
        internal_dpg.configure_item(item, show=False)
Esempio n. 16
0
def popup(parent: Union[int, str],
          mousebutton: int = internal_dpg.mvMouseButton_Right,
          modal: bool = False,
          tag: Union[int, str] = 0) -> int:
    """ Popup widget. """
    try:
        if tag == 0:
            _internal_popup_id = internal_dpg.generate_uuid()
        else:
            _internal_popup_id = tag
        _handler_reg_id = internal_dpg.add_item_handler_registry()
        internal_dpg.add_item_clicked_handler(
            mousebutton,
            parent=internal_dpg.last_item(),
            callback=lambda: internal_dpg.configure_item(_internal_popup_id,
                                                         show=True))
        internal_dpg.bind_item_handler_registry(parent, _handler_reg_id)
        if modal:
            internal_dpg.add_window(modal=True,
                                    show=False,
                                    tag=_internal_popup_id,
                                    autosize=True)
        else:
            internal_dpg.add_window(popup=True,
                                    show=False,
                                    tag=_internal_popup_id,
                                    autosize=True)
        internal_dpg.push_container_stack(internal_dpg.last_container())
        yield _internal_popup_id

    finally:
        internal_dpg.pop_container_stack()
Esempio n. 17
0
def popup(parent: Union[int, str], mousebutton: int = internal_dpg.mvMouseButton_Right, modal: bool = False) -> int:
    
    try:
        _internal_popup_id = internal_dpg.generate_uuid()
        internal_dpg.add_clicked_handler(parent, mousebutton, callback=lambda: internal_dpg.configure_item(_internal_popup_id, show=True))
        if modal:
            internal_dpg.add_window(modal=True, show=False, id=_internal_popup_id, autosize=True)
        else:
            internal_dpg.add_window(popup=True, show=False, id=_internal_popup_id, autosize=True)
        internal_dpg.push_container_stack(internal_dpg.last_container())
        yield _internal_popup_id

    finally:
        internal_dpg.pop_container_stack()
Esempio n. 18
0
def configure_item(item: Union[int, str], **kwargs) -> None:
    """Configures an item after creation."""
    internal_dpg.configure_item(item, **kwargs)
Esempio n. 19
0
def popup(parent: Union[int, str],
          mousebutton: int = internal_dpg.mvMouseButton_Right,
          modal: bool = False,
          tag: Union[int, str] = 0,
          min_size: Union[List[int], Tuple[int, ...]] = [100, 100],
          max_size: Union[List[int], Tuple[int, ...]] = [30000, 30000],
          no_move: bool = False,
          no_background: bool = False) -> int:
    """A window that will be displayed when a parent item is hovered and the corresponding mouse button has been clicked. By default a popup will shrink fit the items it contains.
    This is useful for context windows, and simple modal window popups.
    When popups are used a modal they have more avaliable settings (i.e. title, resize, width, height) These
    can be set by using configure item. 
    This is a light wrapper over window. For more control over a modal|popup window use a normal window with the modal|popup keyword 
    and set the item handler and mouse events manually.

    Args:
        parent: The UI item that will need to be hovered.
        **mousebutton: The mouse button that will trigger the window to popup.
        **modal: Will force the user to interact with the popup.
        **min_size: New in 1.4. Minimum window size.
        **max_size: New in 1.4. Maximum window size.
        **no_move: New in 1.4. Prevents the window from moving based on user input.
        **no_background: New in 1.4. Sets Background and border alpha to transparent.

    Returns:
        item's uuid
    """
    try:
        if tag == 0:
            _internal_popup_id = internal_dpg.generate_uuid()
        else:
            _internal_popup_id = tag
        _handler_reg_id = internal_dpg.add_item_handler_registry()
        internal_dpg.add_item_clicked_handler(
            mousebutton,
            parent=internal_dpg.last_item(),
            callback=lambda: internal_dpg.configure_item(_internal_popup_id,
                                                         show=True))
        internal_dpg.bind_item_handler_registry(parent, _handler_reg_id)
        if modal:
            internal_dpg.add_window(modal=True,
                                    show=False,
                                    tag=_internal_popup_id,
                                    autosize=True,
                                    min_size=min_size,
                                    max_size=max_size,
                                    no_move=no_move,
                                    no_background=no_background)
        else:
            internal_dpg.add_window(popup=True,
                                    show=False,
                                    tag=_internal_popup_id,
                                    autosize=True,
                                    min_size=min_size,
                                    max_size=max_size,
                                    no_move=no_move,
                                    no_background=no_background)
        internal_dpg.push_container_stack(internal_dpg.last_container())
        yield _internal_popup_id

    finally:
        internal_dpg.pop_container_stack()
Esempio n. 20
0
 def hide(self):
     """
     Refer:
     >>> dpg.hide_item
     """
     internal_dpg.configure_item(self.dpg_id, show=False)
Esempio n. 21
0
 def disable(self):
     """
     Refer:
     >>> dpg.disable_item
     """
     internal_dpg.configure_item(self.dpg_id, enabled=False)
Esempio n. 22
0
 def enable(self):
     """
     Refer:
     >>> dpg.enable_item
     """
     internal_dpg.configure_item(self.dpg_id, enabled=True)
Esempio n. 23
0
 def show(self):
     """
     Refer:
     >>> dpg.show_item
     """
     internal_dpg.configure_item(self.dpg_id, show=True)