Omniverse CODE UI queries

Hi everyone! Thanks as always for your support!

I have a few questions re: creating UI via Omniverse Kit/Code:

  • CollapsableFrame objects can’t be created together without a prior VStack; is this intentional?

  • Is there a way to automatically collapse CollapsableFrames on creation? I can’t seem to find any documentation for it if it is possible

  • When two or more CollapsableFrames are added into a UI, I experience jittering from the scrollwheel as I try to reach the bottom UI elements; is this something that can easily be addressed?

  • FloatUI Sliders are often unresponsive to double-clicks to edit the values; dragging is often ok.

  • Do you have a recommended means of creating more complex UI in Code without having so many indents in python? When trying to organize UI, I find that I end up with a very nested hierarchy of objects, and maybe I could implement better practices for this.

I’m running Code version 22.1.3, and the workstation specs are as follows:

CPU: 11th Gen Intel Core I5 - 11400F @2.60 GHz 6 cores
RAM: 16GB
STORAGE: 1TB SSD
GPU: NVIDIA GeForce RTX 3060 (12GB)

Thanks for your help in advance!

Hi @natalia1. Thanks for the questions.

  1. CollapsableFrames can be added to any Container widget. VStack is not required.
  2. There is a collapsed keyword arg for the contructor.
    Here’s an example covering 1 & 2:
import omni.ui as ui

my_window = ui.Window("Example Window", width=300, height=300)
with my_window.frame:
	with ui.HStack():
		ui.CollapsableFrame("Hello")
		with ui.CollapsableFrame("World", collapsed=True):
			with ui.VStack():
				f = ui.FloatField()
				def clicked(f=f):
					print("clicked")
					f.model.set_value(f.model.get_value_as_float() + 1)
		
				ui.Button("Plus One", clicked_fn=clicked)
  1. I’m unable to repro that issue. CollapsableFrame is used extensively in our Property Window too without issue. Do you have an example?
  2. You need to use Ctrl+Click to be able to keyboard in a number. Clicking in these fields causes the slider to snap to the value. You can use a FloatField and Slider in conjunction if you want double-click functionality.
  3. You can organize sections of your UI in classes. You can put the build logic in the constructor of the section classes so that you maintain the same declarative pattern that we have with the built-in widgets. I have an example of this here: mc-widget-library/_widgets.py at main · mati-nvidia/mc-widget-library · GitHub

Hi @mati-nvidia , thank you so much for getting back to us so quickly and providing really helpful answers! I think this answers most of my questions.

Re: point 1, is the initial VStack necessary in order to view these collapsableFrames? As when I create a window without it and create two CollapsableFrames, only the latter shows (as seen in screenshots)

Without VStack:


With VStack:


Re: point 3, here’s a video reference of the stutter occurring both with click and drag from the mouse and with the mouse scrollwheel being used to scroll on this UI.

Hi @natalia1. That example has the containers in a Frame. Frames only support one child. If you put it into a container that supports multiple children (e.g. HStack, ZStack, VGrid, etc.) it should work.

Thanks for the video. I’ll try to repro the scroll issue again. If you can share that window code too, it might help narrow it down.

Hi @mati-nvidia ,

Thanks for the clarification!

Here’s the code for the scroll issue test case:

self._window = ui.Window("My Window", width=300, height=300)
        with self._window.frame:
            with ui.VStack():
                with ui.CollapsableFrame("MyFrame1"):
                    with ui.VStack():
                        ui.Label("Some Label")

                        def on_click():
                            print("clicked!")

                        ui.Button("Click Me", clicked_fn=lambda: on_click())

                        ui.Button("Temp Button")

                        ui.Label("Test Slider 1")
                        ui.FloatDrag(min=0, max=100)

                        ui.Label("Test Slider 2")
                        ui.FloatDrag(min=0, max=100)

                with ui.CollapsableFrame("MyFrame2"):
                    with ui.VStack():
                        ui.Label("Some Slider")

                        ui.IntSlider(min=0, max=100)

                        ui.Label("Some Other Slider")
                        ui.FloatDrag(min=0, max=100)

                        ui.Label("One more slider")
                        ui.FloatDrag(min=0, max=100)

                        ui.Label("One more slider")
                        ui.FloatDrag(min=0, max=100)

                        def on_click():
                            print("clicked!")

                        ui.Button("Click Me", clicked_fn=lambda: on_click())

Thanks again for all your support!

Thanks @natalia1! I was able to repro it. I created issue OM-61554 for the dev team.

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