Window
A Window
is a viewing area that typically contains one or more UI elements. Many extensions have a main window for its UI.
Create a Window
The following code shows how to create a Window
. Commonly an extension will create it’s UI within a Window
in its on_startup
. Once you’ve created a window you use its frame
to add widgets to.
def on_startup(self, ext_id):
my_window = ui.Window("My Extension's Window", width=400, height=400)
with my_window.frame:
ui.Label("My Window with this Label")
Keyword Arguments:
Show...
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
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.
Properies / Methods:
Show...
def call_key_pressed_fn(self, 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.
def deferred_dock_in(self, target_window: str, active_window: DockPolicy = DockPolicy.DO_NOTHING) -> 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.
def destroy(self) -> None:
Removes all the callbacks and circular references.
def dock_in_window(self, title: str, dockPosition: 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 when false is return, otherwise true
def get_window_callback(*args, **kwargs) -> typing.Any:
Returns window set draw callback pointer for the given UI window.
def has_key_pressed_fn(self) -> bool:
Sets the function that will be called when the user presses the keyboard key on the focused window.
def move_to_app_window(self, arg0: omni.appwindow._appwindow.IAppWindow) -> None:
Moves the window to the specific OS window.
def notify_app_window_change(self, arg0: omni.appwindow._appwindow.IAppWindow) -> None:
Notifies the window that window set has changed.
def setPosition(self, x: float, y: float) -> None:
This property set/get the position of the window in both axis calling the property.
def set_docked_changed_fn(self, arg0: typing.Callable[[bool], None]) -> None:
Has true if this window is docked. False otherwise. It’s a read-only property.
def set_focused_changed_fn(self, arg0: typing.Callable[[bool], None]) -> None:
Read only property that is true when the window is focused.
def set_height_changed_fn(self, arg0: typing.Callable[[float], None]) -> None:
This property holds the window Height.
def set_key_pressed_fn(self, fn: typing.Callable[[int, int, bool], None]) -> None:
Sets the function that will be called when the user presses the keyboard key on the focused window.
def set_position_x_changed_fn(self, arg0: typing.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.
def set_position_y_changed_fn(self, arg0: typing.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.
def set_selected_in_dock_changed_fn(self, arg0: typing.Callable[[bool], None]) -> None:
Has true if this window is currently selected in the dock. False otherwise. It’s a read-only property.
def set_top_modal(self) -> None:
Brings this window to the top level of modal windows.
def set_visibility_changed_fn(self, arg0: typing.Callable[[bool], None]) -> None:
This property holds whether the window is visible.
def set_width_changed_fn(self, arg0: typing.Callable[[float], None]) -> None:
This property holds the window Width.
def app_window(self) -> omni.appwindow._appwindow.IAppWindow:
type : omni.appwindow._appwindow.IAppWindow
def auto_resize(self) -> bool:
setup the window to resize automatically based on its content type : bool
def auto_resize(self, arg1: bool) -> None:
setup the window to resize automatically based on its content
def detachable(self) -> bool:
If the window is able to be separated from the main application window. type : bool
def detachable(self, arg1: bool) -> None:
If the window is able to be separated from the main application window.
def docked(self) -> bool:
Has true if this window is docked. False otherwise. It’s a read-only property. type : bool
def exclusive_keyboard(self) -> bool:
When true, only the current window will receive keyboard events when it’s focused. It’s useful to override the global key bindings. type : bool
def exclusive_keyboard(self, arg1: bool) -> None:
When true, only the current window will receive keyboard events when it’s focused. It’s useful to override the global key bindings.
def flags(self) -> int:
This property set the Flags for the Window. type : int
def flags(self, arg1: int) -> None:
This property set the Flags for the Window.
def focus_policy(self) -> FocusPolicy:
Property that controls how a window becomes focused. type : FocusPolicy
def focus_policy(self, arg1: FocusPolicy) -> None:
Property that controls how a window becomes focused.
def focused(self) -> bool:
Read only property that is true when the window is focused. type : bool
def frame(self) -> Frame:
The main layout of this window. type : Frame
def height(self) -> float:
This property holds the window Height. type : float
def height(self, arg1: float) -> None:
This property holds the window Height.
def menu_bar(self) -> MenuBar:
type : MenuBar
def noTabBar(self) -> bool:
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 type : bool
def noTabBar(self, arg1: bool) -> None:
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
def padding_x(self) -> float:
This property set the padding to the frame on the X axis. type : float
def padding_x(self, arg1: float) -> None:
This property set the padding to the frame on the X axis.
def padding_y(self) -> float:
This property set the padding to the frame on the Y axis. type : float
def padding_y(self, arg1: float) -> None:
This property set the padding to the frame on the Y axis.
def position_x(self) -> float:
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. type : float
def position_x(self, arg1: float) -> 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.
def position_y(self) -> float:
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. type : float
def position_y(self, arg1: float) -> 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.
def selected_in_dock(self) -> bool:
Read only property that is true when the window’s tab is selected in a tab group. type : bool
def title(self) -> str:
This property holds the window’s title. type : str
def title(self, arg1: str) -> None:
This property holds the window’s title.
def visible(self) -> bool:
This property holds whether the window is visible. type : bool
def visible(self, arg1: bool) -> None:
This property holds whether the window is visible.
def width(self) -> float:
This property holds the window Width. type : float
def width(self, arg1: float) -> None:
This property holds the window Width.