CollapsableFrame keeps taking the space after collapsed

Hi,

I am writing a simple GUI with a VStack containing 3 CollapsableFrame. My problem is that when I collapse the frame it basically just hides the components inside put keeps taking the place it usually occupies, meaning the components below it don’t move up. I would like to have a behavior similar to how the different section in the Property window work when collapsed/expanded.
This is my GUI code:

        with self._window.frame:
            with ui.VStack(spacing=6):
                with ui.CollapsableFrame("Load PC"):
                    with ui.Frame():
                        self.file_browser_menu.build_ui()
                with ui.CollapsableFrame("Object Detection"):
                    with ui.Frame():
                        self.object_detection_menu.build_ui()
                with ui.CollapsableFrame("Pose Estimation"):
                    with ui.Frame():
                        self.pose_estimation_menu.build_ui()

Hi @anthony.yaghi! Good question! The issue is that the VStack still expands to fill the height of the window frame and it’s children expand as well. If you set the VStack height to zero, it will take up the minimum space it needs shrink and expand based on its children:

import omni.ui as ui

my_window = ui.Window("Example Window", width=300, height=300)
with my_window.frame:
   # I added height=0 here
    with ui.VStack(spacing=6, height=0):
        with ui.CollapsableFrame("Load PC"):
            with ui.Frame():
                ui.Button("Hi")
        with ui.CollapsableFrame("Object Detection"):
            with ui.Frame():
                ui.Button("Hi")
        with ui.CollapsableFrame("Pose Estimation"):
            with ui.Frame():
                ui.Button("Hi")

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.