omni.kit.window.property: Property Window Extension

Property Window

class omni.kit.window.property.GroupHeaderContextMenu

Bases: object

destroy()
classmethod on_mouse_event(event: omni.kit.window.property.templates.header_context_menu.GroupHeaderContextMenuEvent)
class omni.kit.window.property.Path(*args, **kwargs)

Bases: pathlib.PurePath

PurePath subclass that can make system calls.

Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.

absolute()

Return an absolute version of this path. This function works even if the path doesn’t point to anything.

No normalization is done, i.e. all ‘.’ and ‘..’ will be kept along. Use resolve() to get the canonical path to a file.

chmod(mode)

Change the permissions of the path, like os.chmod().

classmethod cwd()

Return a new path pointing to the current working directory (as returned by os.getcwd()).

exists()

Whether this path exists.

expanduser()

Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)

glob(pattern)

Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.

group()

Return the group name of the file gid.

classmethod home()

Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).

is_block_device()

Whether this path is a block device.

is_char_device()

Whether this path is a character device.

is_dir()

Whether this path is a directory.

is_fifo()

Whether this path is a FIFO.

is_file()

Whether this path is a regular file (also True for symlinks pointing to regular files).

is_mount()

Check if this path is a POSIX mount point

is_socket()

Whether this path is a socket.

Whether this path is a symbolic link.

iterdir()

Iterate over the files in this directory. Does not yield any result for the special paths ‘.’ and ‘..’.

lchmod(mode)

Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.

lstat()

Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.

mkdir(mode=511, parents=False, exist_ok=False)

Create a new directory at this given path.

open(mode='r', buffering=- 1, encoding=None, errors=None, newline=None)

Open the file pointed by this path and return a file object, as the built-in open() function does.

owner()

Return the login name of the file owner.

read_bytes()

Open the file in bytes mode, read it, and close the file.

read_text(encoding=None, errors=None)

Open the file in text mode, read it, and close the file.

rename(target)

Rename this path to the given path.

replace(target)

Rename this path to the given path, clobbering the existing destination if it exists.

resolve(strict=False)

Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows).

rglob(pattern)

Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.

rmdir()

Remove this directory. The directory must be empty.

samefile(other_path)

Return whether other_path is the same or not as this file (as returned by os.path.samefile()).

stat()

Return the result of the stat() system call on this path, like os.stat() does.

Make this path a symlink pointing to the given path. Note the order of arguments (self, target) is the reverse of os.symlink’s.

touch(mode=438, exist_ok=True)

Create this file with the given access mode, if it doesn’t exist.

Remove this file or link. If the path is a directory, use rmdir() instead.

write_bytes(data)

Open the file in bytes mode, write to it, and close the file.

write_text(data, encoding=None, errors=None)

Open the file in text mode, write to it, and close the file.

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.

property paused

Gets if property window refresh is paused.

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 (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.

request_rebuild()

Requests the entire property window to be rebuilt.

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.

Parameters
  • scheme (str) – Scheme of the PropertySchemeDelegate order to be added to.

  • layout (List(str)) – a list of PropertySchemeDelegate’s name, in the order of being processed when building UI. Scheme delegate not in this will be skipped.

set_visibility_changed_listener(listener)
set_visible(visible: bool)
unregister_scheme_delegate(scheme: str, name: str)

Unregister a PropertySchemeDelegate from PropertyWindow by name.

Parameters
  • scheme (str) – Scheme of the PropertySchemeDelegate to be removed from.

  • name (str) – The name to find the PropertySchemeDelegate and remove.

unregister_widget(scheme: str, name: str, top_stack: bool = True)

Unregister a PropertyWidget from PropertyWindow.

Parameters
  • scheme (str) – Scheme of the PropertyWidget to be removed from.

  • name (str) – The name to find the PropertyWidget and remove.

  • top_stack (bool) – see @register_widget

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.

abstract get_widgets(payload)List[str]

Tests the payload and gathers widgets in interest to be drawn in specific order.

Property Widgets Templates

class omni.kit.window.property.templates.GroupHeaderContextMenu

Bases: object

destroy()
classmethod on_mouse_event(event: omni.kit.window.property.templates.header_context_menu.GroupHeaderContextMenuEvent)
class omni.kit.window.property.templates.GroupHeaderContextMenuEvent(group_id: str, payload: Any)

Bases: object

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, editable: bool = False, identifier: Optional[str] = None)

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.

  • editable – If the StringField generated from model should be editable. Default is False.

build_impl()

See PropertyWidget.build_impl

build_items()

When deriving from SimplePropertyWidget, override this function to build your items.

clean()

See PropertyWidget.clean

on_new_payload(payload, ignore_large_selection=False)bool

See PropertyWidget.on_new_payload

request_rebuild()

Request the window to rebuild. It will be rebuilt on next frame.

reset()

See PropertyWidget.reset