Window

class omni.ui.Window

Bases: WindowHandle

The Window class represents a window in the underlying windowing system. This window is a child window of main Kit window. And it can be docked. Rasterization omni.ui generates vertices every frame to render UI elements. One of the features of the framework is the ability to bake a DrawList per window and reuse it if the content has not changed, which can significantly improve performance. However, in some cases, such as the Viewport window and Console window, it may not be possible to detect whether the window content has changed, leading to a frozen window. To address this problem, you can control the rasterization behavior by adjusting RasterPolicy. The RasterPolicy is an enumeration class that defines the rasterization behavior of a window. It has three possible values: NEVER: Do not rasterize the widget at any time. ON_DEMAND: Rasterize the widget as soon as possible and always use the rasterized version. The widget will only be updated when the user calls invalidateRaster. AUTO: Automatically determine whether to rasterize the widget based on performance considerations. If necessary, the widget will be rasterized and updated when its content changes. To resolve the frozen window issue, you can manually set the RasterPolicy of the problematic window to Never. This will force the window to rasterize its content and use the rasterized version until the user explicitly calls invalidateRaster to request an update. window = ui.Window(“Test window”, raster_policy=ui.RasterPolicy.NEVER)

Methods

__init__(self, title, dockPreference, **kwargs)

Construct the window, add it to the underlying windowing system, and makes it appear.

call_key_pressed_fn(self, arg0, arg1, arg2)

Sets the function that will be called when the user presses the keyboard key on the focused window.

deferred_dock_in(self, target_window, ...)

Deferred docking.

destroy(self)

Removes all the callbacks and circular references.

dock_in_window(self, title, dockPosition[, ...])

place the window in a specific docking position based on a target window name.

get_window_callback(self)

Returns window set draw callback pointer for the given UI window.

has_key_pressed_fn(self)

Sets the function that will be called when the user presses the keyboard key on the focused window.

move_to_app_window(self, arg0)

Moves the window to the specific OS window.

move_to_main_os_window(self)

Bring back the Window callback to the Main Window and destroy the Current OS Window.

move_to_new_os_window(self)

Move the Window Callback to a new OS Window.

notify_app_window_change(self, arg0)

Notifies the window that window set has changed.

setPosition(self, x, y)

This property set/get the position of the window in both axis calling the property.

set_docked_changed_fn(self, arg0)

Has true if this window is docked.

set_focused_changed_fn(self, arg0)

Read only property that is true when the window is focused.

set_height_changed_fn(self, arg0)

This property holds the window Height.

set_key_pressed_fn(self, fn)

Sets the function that will be called when the user presses the keyboard key on the focused window.

set_position_x_changed_fn(self, arg0)

This property set/get the position of the window in the X Axis.

set_position_y_changed_fn(self, arg0)

This property set/get the position of the window in the Y Axis.

set_selected_in_dock_changed_fn(self, arg0)

Has true if this window is currently selected in the dock.

set_top_modal(self)

Brings this window to the top level of modal windows.

set_visibility_changed_fn(self, arg0)

This property holds whether the window is visible.

set_width_changed_fn(self, arg0)

This property holds the window Width.

Attributes

app_window

auto_resize

setup the window to resize automatically based on its content

detachable

If the window is able to be separated from the main application window.

docked

Has true if this window is docked.

exclusive_keyboard

When true, only the current window will receive keyboard events when it's focused.

flags

This property set the Flags for the Window.

focus_policy

How the Window gains focus.

focused

Read only property that is true when the window is focused.

frame

The main layout of this window.

height

This property holds the window Height.

menu_bar

noTabBar

setup the visibility of the TabBar Handle, this is the small triangle at the corner of the view If it is not shown then it is not possible to undock that window and it need to be closed/moved programatically

padding_x

This property set the padding to the frame on the X axis.

padding_y

This property set the padding to the frame on the Y axis.

position_x

This property set/get the position of the window in the X Axis.

position_y

This property set/get the position of the window in the Y Axis.

raster_policy

Determine how the content of the window should be rastered.

selected_in_dock

Has true if this window is currently selected in the dock.

tabBar_tooltip

This property sets the tooltip when hovering over window's tabbar.

title

This property holds the window's title.

visible

This property holds whether the window is visible.

width

This property holds the window Width.

__init__(self: omni.ui._ui.Window, title: str, dockPreference: omni.ui._ui.DockPreference = <DockPreference.DISABLED: 0>, **kwargs) None

Construct the window, add it to the underlying windowing system, and makes it appear.

### Arguments:

`title :`

The window title. It’s also used as an internal window ID.

`dockPrefence :`

In the old Kit determines where the window should be docked. In Kit Next it’s unused.

`kwargsdict`

See below

### Keyword Arguments:

`flags`

This property set the Flags for the Window.

`visible`

This property holds whether the window is visible.

`title`

This property holds the window’s title.

`padding_x`

This property set the padding to the frame on the X axis.

`padding_y`

This property set the padding to the frame on the Y axis.

`width`

This property holds the window Width.

`height`

This property holds the window Height.

`position_x`

This property set/get the position of the window in the X Axis. The default is kWindowFloatInvalid because we send the window position to the underlying system only if the position is explicitly set by the user. Otherwise the underlying system decides the position.

`position_y`

This property set/get the position of the window in the Y Axis. The default is kWindowFloatInvalid because we send the window position to the underlying system only if the position is explicitly set by the user. Otherwise the underlying system decides the position.

`auto_resize`

setup the window to resize automatically based on its content

`noTabBar`

setup the visibility of the TabBar Handle, this is the small triangle at the corner of the view If it is not shown then it is not possible to undock that window and it need to be closed/moved programatically

`tabBarTooltip`

This property sets the tooltip when hovering over window’s tabbar.

`raster_policy`

Determine how the content of the window should be rastered.

`width_changed_fn`

This property holds the window Width.

`height_changed_fn`

This property holds the window Height.

`visibility_changed_fn`

This property holds whether the window is visible.

call_key_pressed_fn(self: omni.ui._ui.Window, arg0: int, arg1: int, arg2: bool) None

Sets the function that will be called when the user presses the keyboard key on the focused window.

deferred_dock_in(self: omni.ui._ui.Window, target_window: str, active_window: omni.ui._ui.DockPolicy = <DockPolicy.DO_NOTHING: 0>) None

Deferred docking. We need it when we want to dock windows before they were actually created. It’s helpful when extension initialization, before any window is created.

### Arguments:

`targetWindowTitle :`

Dock to window with this title when it appears.

`activeWindow :`

Make target or this window active when docked.

destroy(self: omni.ui._ui.Window) None

Removes all the callbacks and circular references.

dock_in_window(self: omni.ui._ui.Window, title: str, dockPosition: omni.ui._ui.DockPosition, ratio: float = 0.5) bool

place the window in a specific docking position based on a target window name. We will find the target window dock node and insert this window in it, either by spliting on ratio or on top if the window is not found false is return, otherwise true

get_window_callback(self: omni.ui._ui.Window) omni::ui::windowmanager::IWindowCallback

Returns window set draw callback pointer for the given UI window.

has_key_pressed_fn(self: omni.ui._ui.Window) bool

Sets the function that will be called when the user presses the keyboard key on the focused window.

move_to_app_window(self: omni.ui._ui.Window, arg0: omni::kit::IAppWindow) None

Moves the window to the specific OS window.

move_to_main_os_window(self: omni.ui._ui.Window) None

Bring back the Window callback to the Main Window and destroy the Current OS Window.

move_to_new_os_window(self: omni.ui._ui.Window) None

Move the Window Callback to a new OS Window.

notify_app_window_change(self: omni.ui._ui.Window, arg0: omni::kit::IAppWindow) None

Notifies the window that window set has changed.

setPosition(self: omni.ui._ui.Window, x: float, y: float) None

This property set/get the position of the window in both axis calling the property.

set_docked_changed_fn(self: omni.ui._ui.Window, arg0: Callable[[bool], None]) None

Has true if this window is docked. False otherwise. It’s a read-only property.

set_focused_changed_fn(self: omni.ui._ui.Window, arg0: Callable[[bool], None]) None

Read only property that is true when the window is focused.

set_height_changed_fn(self: omni.ui._ui.Window, arg0: Callable[[float], None]) None

This property holds the window Height.

set_key_pressed_fn(self: omni.ui._ui.Window, fn: Callable[[int, int, bool], None]) None

Sets the function that will be called when the user presses the keyboard key on the focused window.

set_position_x_changed_fn(self: omni.ui._ui.Window, arg0: Callable[[float], None]) None

This property set/get the position of the window in the X Axis. The default is kWindowFloatInvalid because we send the window position to the underlying system only if the position is explicitly set by the user. Otherwise the underlying system decides the position.

set_position_y_changed_fn(self: omni.ui._ui.Window, arg0: Callable[[float], None]) None

This property set/get the position of the window in the Y Axis. The default is kWindowFloatInvalid because we send the window position to the underlying system only if the position is explicitly set by the user. Otherwise the underlying system decides the position.

set_selected_in_dock_changed_fn(self: omni.ui._ui.Window, arg0: Callable[[bool], None]) None

Has true if this window is currently selected in the dock. False otherwise. It’s a read-only property.

set_top_modal(self: omni.ui._ui.Window) None

Brings this window to the top level of modal windows.

set_visibility_changed_fn(self: omni.ui._ui.Window, arg0: Callable[[bool], None]) None

This property holds whether the window is visible.

set_width_changed_fn(self: omni.ui._ui.Window, arg0: Callable[[float], None]) None

This property holds the window Width.

property auto_resize

setup the window to resize automatically based on its content

property detachable

If the window is able to be separated from the main application window.

property docked

Has true if this window is docked. False otherwise. It’s a read-only property.

property exclusive_keyboard

When true, only the current window will receive keyboard events when it’s focused. It’s useful to override the global key bindings.

property flags

This property set the Flags for the Window.

property focus_policy

How the Window gains focus.

property focused

Read only property that is true when the window is focused.

property frame

The main layout of this window.

property height

This property holds the window Height.

property noTabBar

setup the visibility of the TabBar Handle, this is the small triangle at the corner of the view If it is not shown then it is not possible to undock that window and it need to be closed/moved programatically

property padding_x

This property set the padding to the frame on the X axis.

property padding_y

This property set the padding to the frame on the Y axis.

property position_x

This property set/get the position of the window in the X Axis. The default is kWindowFloatInvalid because we send the window position to the underlying system only if the position is explicitly set by the user. Otherwise the underlying system decides the position.

property position_y

This property set/get the position of the window in the Y Axis. The default is kWindowFloatInvalid because we send the window position to the underlying system only if the position is explicitly set by the user. Otherwise the underlying system decides the position.

property raster_policy

Determine how the content of the window should be rastered.

property selected_in_dock

Has true if this window is currently selected in the dock. False otherwise. It’s a read-only property.

property tabBar_tooltip

This property sets the tooltip when hovering over window’s tabbar.

property title

This property holds the window’s title.

property visible

This property holds whether the window is visible.

property width

This property holds the window Width.