Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodes with the first attribute "empty" expand infinitely in width #2444

Open
n3odym3 opened this issue Dec 8, 2024 · 0 comments
Open

Nodes with the first attribute "empty" expand infinitely in width #2444

n3odym3 opened this issue Dec 8, 2024 · 0 comments
Labels
state: pending not addressed yet type: bug bug

Comments

@n3odym3
Copy link

n3odym3 commented Dec 8, 2024

Version of Dear PyGui

Version: 2.0.0
Operating System: Windows 11

My Issue/Question

In DearPyGui 2.0, nodes exhibit unintended width expansion under the following conditions:

The node has an empty first attribute (either input/output/static) or the node contains an empty nested attribute (with no nested child, e.g., no text). This issue causes the node to expand slightly on each render.

This behavior is observed on DPG 2.0 but is not present in DPG 1.8.0, where nodes work as expected.

Bug occurs:

  1. Node with an empty input and an empty output attribute.
  2. Node with an empty input and a filled output attribute.

Works correctly:

  1. Node with a filled input and a filled output attribute.
  2. Node with a filled input and an empty output attribute.

The bug seems to come from the automatic sizing mechanism, which fails to determine the node's width correctly if the first child attribute is empty.

Adding a time.sleep(0.25) to slow the framerate confirms that the node extend progressively on each render instead of being created with an infinite width.

Adding an empty string to the first attribute can mitigate the issue, but this increases the node's height slightly.

To Reproduce

Steps to reproduce the behavior:

  1. Create a node_editor
  2. Add an empty node with either
    A. dpg.add_node()
    B. with dpg.node(): pass
  3. Or add a node with the FIRST attribute empty :
    A. with dpg.node(): dpg.add_node_attribute(attribute_type=dpg.mvNode_Attr_Output)
    B. with dpg.node(): with dpg.node_attribute(attribute_type=dpg.mvNode_Attr_Output) : pass

Expected behavior

The node should have a fixed width that scale to the size of the node label (if the node does not have children) or the largest attribute (if the node have one or more children).

Screenshot

BuggedNodeEditor

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport(title="Expanding node bug", width=1280, height=720)

with dpg.window(label="Node Editor", width=1280, height=720):
    with dpg.node_editor(tag="node_editor", minimap=True, minimap_location=dpg.mvNodeMiniMap_Location_BottomRight):

        dpg.add_node(label="Bugged node 1", pos=[100, 0])

        with dpg.node(label="Bugged node 2", pos=[100, 50]):
            pass

        with dpg.node(label="Bugged node 3", pos=[100, 100]):
            dpg.add_node_attribute(label="Input", attribute_type=dpg.mvNode_Attr_Output)

        with dpg.node(label="Bugged node 4", pos=[100, 150]):
            with dpg.node_attribute(label="Test", attribute_type=dpg.mvNode_Attr_Output) :
                pass
        
        with dpg.node(label="Working node 1", pos=[100, 250]):
            with dpg.node_attribute(label="Test", attribute_type=dpg.mvNode_Attr_Output) :
                dpg.add_text("This is a working node if the attribute have a child")
        
        with dpg.node(label="Bugged node fixed with empty string", pos=[100, 325]):
            with dpg.node_attribute(label="Test", attribute_type=dpg.mvNode_Attr_Output) :
                dpg.add_text("")

        with dpg.node(label="Bugged node 5", pos=[100, 450]):
            dpg.add_node_attribute(label="Input", attribute_type=dpg.mvNode_Attr_Input)

            with dpg.node_attribute(label="Test", attribute_type=dpg.mvNode_Attr_Output) :
                dpg.add_text("If the first attribute is empty the node will be bugged")
        
        with dpg.node(label="Bugged node 5 fixed", pos=[100, 525]):
            with dpg.node_attribute(label="Test", attribute_type=dpg.mvNode_Attr_Output) :
                dpg.add_text("If the first attribute have a child the node will be working correctly")
            
            dpg.add_node_attribute(label="Input", attribute_type=dpg.mvNode_Attr_Input)

dpg.setup_dearpygui()
dpg.show_viewport()

import time

while dpg.is_dearpygui_running():
    dpg.render_dearpygui_frame()
    time.sleep(0.25)

dpg.destroy_context()
@n3odym3 n3odym3 added state: pending not addressed yet type: bug bug labels Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: pending not addressed yet type: bug bug
Projects
None yet
Development

No branches or pull requests

1 participant