hoffstadt / hoffstadt/DearPyGui
Nodes with the first attribute "empty" expand infinitely in width
- Dominant language
- C++
- Stars
- 15.6k
- Forks
- 783
- PR merge metrics
- No merged PRs in 30d
Description
## 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
6. Add an empty node with either
A. ```dpg.add_node()```
B. ```with dpg.node():
pass```
7. 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

## Standalone, minimal, complete and verifiable example
```python
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()
```
Contributor guide
Assessment
This issue has not been assessed yet.