DearPyGui icon indicating copy to clipboard operation
DearPyGui copied to clipboard

Windows containing a collapsing_header inside a group expand over time when autosize=True

Open ndahn opened this issue 9 months ago • 4 comments

Version: 2.0.0 Operating System: Ubuntu 22.04

My Issue/Question

When creating a window with the following properties:

  • autosize = True
  • containing a group
  • and a collapsing_header inside that group

the collapsing header and thus the window will expand over time if the collapsing_header does not show any items (either because it's empty or doesn't have any). See the code below. Opening the collapsing_header to show its items resets the window size, assuming it has any items.

Curiously, this does not happen if the collapsing_header is not inside a group. However, setting a size on a containing group does not prevent this.

Image

Expected Behavior

I would have expected that the collapsing_header either fills its container or keeps to the size of its children.

Minimal standalone example

"""The dearpygui demo, used for reference."""

import dearpygui.dearpygui as dpg
import dearpygui.demo as demo

dpg.create_context()
dpg.create_viewport(title="Custom Title", width=600, height=600)

#demo.show_demo()
with dpg.window(autosize=True):
    with dpg.group():
        dpg.add_collapsing_header(label="Empty")

with dpg.window(autosize=True):
    with dpg.group():
        with dpg.collapsing_header(label="With items"):
                dpg.add_text("Item 1")
                dpg.add_text("Item 2")
                dpg.add_text("Item 3")

with dpg.window(autosize=True):
    dpg.add_collapsing_header(label="Empty without group")

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

ndahn avatar Apr 11 '25 12:04 ndahn

As a workaround, placing the collapsing headers inside a child_window works as I would have imagined it.

with dpg.child_window(border=False, auto_resize_y=True):
    with dpg.collapsing_header(label="workaround"):
        ...

ndahn avatar Apr 11 '25 12:04 ndahn

I haven't checked it but most probably it is yet another manifestation of Dear ImGui issue 7543 - see my comment in that ticket. If my hypothesis is true, nothing we can do on DPG side - the issue needs to be fixed in Dear ImGui.

v-ein avatar Apr 11 '25 17:04 v-ein

Please don't click the link in the notification you received for the previous comment. It's a scam.

v-ein avatar Apr 16 '25 18:04 v-ein