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:
CollapsableFrames can be added to any Container widget. VStack is not required.
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)
I’m unable to repro that issue. CollapsableFrame is used extensively in our Property Window too without issue. Do you have an example?
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.
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)
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.