Property Window Extension¶
Property Window¶
-
class
omni.kit.window.property.
PropertyWindow
¶ Bases:
object
-
destroy
()¶
-
get_scheme
()¶ Gets the current scheme being displayed in Property Window.
-
notify
(scheme: str, payload)¶ Notify Property Window of a scheme and/or payload change. This is the function to trigger refresh of PropertyWindow.
- Parameters
scheme (str) – Scheme of this notification.
payload – Payload to refresh the widgets.
-
register_scheme_delegate
(scheme: str, name: str, delegate: omni.kit.window.property.property_scheme_delegate.PropertySchemeDelegate)¶ Register a PropertySchemeDelegate for a given scheme. A PropertySchemeDelegate tests the payload and determines what widgets to be drawn in what order. A scheme can have multiple PropertySchemeDelegate and their result will be merged to display all relevant widgets.
PropertySchemeDelegate does not hide widgets that are not returned from its get_widgets function. If you want to hide certain widget, return them in PropertySchemeDelegate.get_unwanted_widgets. See PropertySchemeDelegate’s documentation for details.
- Parameters
scheme (str) – Scheme of the PropertySchemeDelegate to be added to.
name (str) – A unique name to identify the PropertySchemeDelegate under. Delegate with existing name will be overridden.
delegate (PropertySchemeDelegate) – A PropertySchemeDelegate instance to be added.
-
register_widget
(scheme: str, name: str, property_widget: omni.kit.window.property.property_widget.PropertyWidget, top_stack: bool = True)¶ Registers a PropertyWidget to PropertyWindow.
- Parameters
scheme (str) – Scheme of the PropertyWidget will work with.
name (str) – A unique name to identify the PropertyWidget under. Widget with existing name will be overridden.
property_widget (PropertyWidget) – A PropertyWidget instance to be added.
top_stack (bool) – Widgets are managed in double stack: True to register the widget to “Top” stack which layouts widgets from top to bottom. False to register the widget to “Button” stack which layouts widgets from bottom to top and always below the “Top” stack.
-
reset_scheme_delegate_layout
(scheme: str)¶ Reset the order so PropertySchemeDelegate will be processed in the order of registration when building UI.
- Parameters
scheme (str) – Scheme of the PropertySchemeDelegate order to be removed from.
-
set_scheme_delegate_layout
(scheme: str, layout: List[str])¶ Register a list of PropertySchemeDelegate’s names to finalize the order and visibility of all registered PropertySchemeDelegate. Useful if you need a fixed layout of Property Widgets for your Kit experience.
- Remark:
If you’re a Property Widget writer, DO NOT call this function. It should only be called by Kit Experience to tune the final look and layout of the Property Window.
-
set_visibility_changed_listener
(listener)¶
-
-
omni.kit.window.property.
get_window
()¶
Property Widget¶
-
class
omni.kit.window.property.property_widget.
PropertyWidget
(title: str)¶ Bases:
object
Base class to create a group of widgets in Property Window
-
build
()¶
-
abstract
build_impl
()¶ Main function to creates the UI elements.
-
abstract
clean
()¶ Clean up function to be called before destorying the object.
-
abstract
on_new_payload
(payload) → bool¶ Called when a new payload is delivered. PropertyWidget can take this opportunity to update its ui models, or schedule full UI rebuild.
- Parameters
payload – The new payload to refresh UI or update model.
- Returns
True if the UI needs to be rebuilt. build_impl will be called as a result. False if the UI does not need to be rebuilt. build_impl will not be called.
-
abstract
reset
()¶ Clean up function to be called when previously built widget is no longer visible given new scheme/payload
-
Property Scheme Delegate¶
-
class
omni.kit.window.property.property_scheme_delegate.
PropertySchemeDelegate
¶ Bases:
object
PropertySchemeDelegate is a class to test given payload and determine what widgets to be drawn in what order.
-
get_unwanted_widgets
(payload) → List[str]¶ Tests the payload and returns a list of widget names which this delegate does not want to include. Note that if there is another PropertySchemeDelegate returning widget in its get_widgets that conflicts with names in get_unwanted_widgets, get_widgets always wins (i.e. the Widget will be drawn).
This function is optional.
-
Property Widgets Templates¶
-
class
omni.kit.window.property.templates.
PropertyWidget
(title: str)¶ Bases:
object
Base class to create a group of widgets in Property Window
-
build
()¶
-
abstract
build_impl
()¶ Main function to creates the UI elements.
-
abstract
clean
()¶ Clean up function to be called before destorying the object.
-
abstract
on_new_payload
(payload) → bool¶ Called when a new payload is delivered. PropertyWidget can take this opportunity to update its ui models, or schedule full UI rebuild.
- Parameters
payload – The new payload to refresh UI or update model.
- Returns
True if the UI needs to be rebuilt. build_impl will be called as a result. False if the UI does not need to be rebuilt. build_impl will not be called.
-
abstract
reset
()¶ Clean up function to be called when previously built widget is no longer visible given new scheme/payload
-
-
class
omni.kit.window.property.templates.
SimplePropertyWidget
(title: str, collapsed: bool = False, collapsable: bool = True)¶ Bases:
omni.kit.window.property.property_widget.PropertyWidget
SimplePropertyWidget provides a simple vertical list of “Label” -> “Value widget” pair layout.
-
add_item
(label: str, value)¶ This function is supposed to be called inside of build_items function. Adds a “Label” -> “Value widget” pair item to the widget. “value” will be an uneditable string in a StringField.
- Parameters
label (str) – The label text of the entry.
value – The value to be stringified and displayed in a StringField.
-
add_item_with_model
(label: str, model)¶ This function is supposed to be called inside of build_items function. Adds a “Label” -> “Value widget with model” pair item to the widget. “value” will be an editable string in a StringField backed by supplied model.
- Parameters
label (str) – The label text of the entry.
model – The model to be used by the string field.
-
build_impl
()¶ See PropertyWidget.build_impl
-
build_items
()¶ When deriving from SimplePropertyWidget, override this function to build your items.
-
clean
()¶ See PropertyWidget.clean
-
request_rebuild
()¶ Request the window to rebuild. It will be rebuilt on next frame.
-
reset
()¶ See PropertyWidget.reset
-