Widget

class omni.ui.Widget

Bases: pybind11_object

The Widget class is the base class of all user interface objects. The widget is the atom of the user interface: it receives mouse, keyboard and other events, and paints a representation of itself on the screen. Every widget is rectangular. A widget is clipped by its parent and by the widgets in front of it.

Methods

__init__(self, **kwargs)

call_accept_drop_fn(self, arg0)

Specify that this Widget can accept specific drops and set the callback that is called to check if the drop can be accepted.

call_computed_content_size_changed_fn(self)

Called when the size of the widget is changed.

call_drag_fn(self)

Specify that this Widget is draggable, and set the callback that is attached to the drag operation.

call_drop_fn(self, arg0)

Specify that this Widget accepts drops and set the callback to the drop operation.

call_key_pressed_fn(self, arg0, arg1, arg2)

Sets the function that will be called when the user presses the keyboard key when the mouse clicks the widget.

call_mouse_double_clicked_fn(self, arg0, ...)

Sets the function that will be called when the user presses the mouse button twice inside the widget.

call_mouse_hovered_fn(self, arg0)

Sets the function that will be called when the user use mouse enter/leave on the focused window.

call_mouse_moved_fn(self, arg0, arg1, arg2, arg3)

Sets the function that will be called when the user moves the mouse inside the widget.

call_mouse_pressed_fn(self, arg0, arg1, ...)

Sets the function that will be called when the user presses the mouse button inside the widget.

call_mouse_released_fn(self, arg0, arg1, ...)

Sets the function that will be called when the user releases the mouse button if this button was pressed inside the widget.

call_mouse_wheel_fn(self, arg0, arg1, arg2)

Sets the function that will be called when the user uses mouse wheel on the focused window.

call_tooltip_fn(self)

Set dynamic tooltip that will be created dynamiclly the first time it is needed.

destroy(self)

Removes all the callbacks and circular references.

has_accept_drop_fn(self)

Specify that this Widget can accept specific drops and set the callback that is called to check if the drop can be accepted.

has_computed_content_size_changed_fn(self)

Called when the size of the widget is changed.

has_drag_fn(self)

Specify that this Widget is draggable, and set the callback that is attached to the drag operation.

has_drop_fn(self)

Specify that this Widget accepts drops and set the callback to the drop operation.

has_key_pressed_fn(self)

Sets the function that will be called when the user presses the keyboard key when the mouse clicks the widget.

has_mouse_double_clicked_fn(self)

Sets the function that will be called when the user presses the mouse button twice inside the widget.

has_mouse_hovered_fn(self)

Sets the function that will be called when the user use mouse enter/leave on the focused window.

has_mouse_moved_fn(self)

Sets the function that will be called when the user moves the mouse inside the widget.

has_mouse_pressed_fn(self)

Sets the function that will be called when the user presses the mouse button inside the widget.

has_mouse_released_fn(self)

Sets the function that will be called when the user releases the mouse button if this button was pressed inside the widget.

has_mouse_wheel_fn(self)

Sets the function that will be called when the user uses mouse wheel on the focused window.

has_tooltip_fn(self)

Set dynamic tooltip that will be created dynamiclly the first time it is needed.

scroll_here(self[, center_ratio_x, ...])

Adjust scrolling amount in two axes to make current item visible.

scroll_here_x(self[, center_ratio])

Adjust scrolling amount to make current item visible.

scroll_here_y(self[, center_ratio])

Adjust scrolling amount to make current item visible.

set_accept_drop_fn(self, fn)

Specify that this Widget can accept specific drops and set the callback that is called to check if the drop can be accepted.

set_checked_changed_fn(self, fn)

This property holds a flag that specifies the widget has to use eChecked state of the style.

set_computed_content_size_changed_fn(self, fn)

Called when the size of the widget is changed.

set_drag_fn(self, fn)

Specify that this Widget is draggable, and set the callback that is attached to the drag operation.

set_drop_fn(self, fn)

Specify that this Widget accepts drops and set the callback to the drop operation.

set_key_pressed_fn(self, fn)

Sets the function that will be called when the user presses the keyboard key when the mouse clicks the widget.

set_mouse_double_clicked_fn(self, fn)

Sets the function that will be called when the user presses the mouse button twice inside the widget.

set_mouse_hovered_fn(self, fn)

Sets the function that will be called when the user use mouse enter/leave on the focused window.

set_mouse_moved_fn(self, fn)

Sets the function that will be called when the user moves the mouse inside the widget.

set_mouse_pressed_fn(self, fn)

Sets the function that will be called when the user presses the mouse button inside the widget.

set_mouse_released_fn(self, fn)

Sets the function that will be called when the user releases the mouse button if this button was pressed inside the widget.

set_mouse_wheel_fn(self, fn)

Sets the function that will be called when the user uses mouse wheel on the focused window.

set_style(self, arg0)

Set the current style.

set_tooltip(self, tooltip_label)

Set a basic tooltip for the widget, this will simply be a Label, it will follow the Tooltip style

set_tooltip_fn(self, fn)

Set dynamic tooltip that will be created dynamiclly the first time it is needed.

Attributes

FLAG_WANT_CAPTURE_KEYBOARD

checked

This property holds a flag that specifies the widget has to use eChecked state of the style.

computed_content_height

Returns the final computed height of the content of the widget.

computed_content_width

Returns the final computed width of the content of the widget.

computed_height

Returns the final computed height of the widget.

computed_width

Returns the final computed width of the widget.

dragging

This property holds if the widget is being dragged.

enabled

This property holds whether the widget is enabled.

height

This property holds the height of the widget relative to its parent.

identifier

An optional identifier of the widget we can use to refer to it in queries.

name

The name of the widget that user can set.

opaque_for_mouse_events

If the widgets has callback functions it will by default not capture the events if it is the top most widget and setup this option to true, so they don't get routed to the child widgets either

screen_position_x

Returns the X Screen coordinate the widget was last draw.

screen_position_y

Returns the Y Screen coordinate the widget was last draw.

scroll_only_window_hovered

When it's false, the scroll callback is called even if other window is hovered.

selected

This property holds a flag that specifies the widget has to use eSelected state of the style.

skip_draw_when_clipped

The flag that specifies if it's necessary to bypass the whole draw cycle if the bounding box is clipped with a scrolling frame.

style

The local style.

style_type_name_override

By default, we use typeName to look up the style.

tooltip

Set a basic tooltip for the widget, this will simply be a Label, it will follow the Tooltip style

tooltip_offset_x

Set the X tooltip offset in points.

tooltip_offset_y

Set the Y tooltip offset in points.

visible

This property holds whether the widget is visible.

visible_max

If the current zoom factor and DPI is bigger than this value, the widget is not visible.

visible_min

If the current zoom factor and DPI is less than this value, the widget is not visible.

width

This property holds the width of the widget relative to its parent.

__init__(self: omni.ui._ui.Widget, **kwargs) None
call_accept_drop_fn(self: omni.ui._ui.Widget, arg0: str) bool

Specify that this Widget can accept specific drops and set the callback that is called to check if the drop can be accepted.

call_computed_content_size_changed_fn(self: omni.ui._ui.Widget) None

Called when the size of the widget is changed.

call_drag_fn(self: omni.ui._ui.Widget) str

Specify that this Widget is draggable, and set the callback that is attached to the drag operation.

call_drop_fn(self: omni.ui._ui.Widget, arg0: omni.ui._ui.WidgetMouseDropEvent) None

Specify that this Widget accepts drops and set the callback to the drop operation.

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

Sets the function that will be called when the user presses the keyboard key when the mouse clicks the widget.

call_mouse_double_clicked_fn(self: omni.ui._ui.Widget, arg0: float, arg1: float, arg2: int, arg3: int) None

Sets the function that will be called when the user presses the mouse button twice inside the widget. The function specification is the same as in setMousePressedFn. void onMouseDoubleClicked(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)

call_mouse_hovered_fn(self: omni.ui._ui.Widget, arg0: bool) None

Sets the function that will be called when the user use mouse enter/leave on the focused window. function specification is the same as in setMouseHovedFn. void onMouseHovered(bool hovered)

call_mouse_moved_fn(self: omni.ui._ui.Widget, arg0: float, arg1: float, arg2: int, arg3: bool) None

Sets the function that will be called when the user moves the mouse inside the widget. Mouse move events only occur if a mouse button is pressed while the mouse is being moved. void onMouseMoved(float x, float y, int32_t modifier)

call_mouse_pressed_fn(self: omni.ui._ui.Widget, arg0: float, arg1: float, arg2: int, arg3: int) None

Sets the function that will be called when the user presses the mouse button inside the widget. The function should be like this: void onMousePressed(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier) Where ‘button’ is the number of the mouse button pressed. ‘modifier’ is the flag for the keyboard modifier key.

call_mouse_released_fn(self: omni.ui._ui.Widget, arg0: float, arg1: float, arg2: int, arg3: int) None

Sets the function that will be called when the user releases the mouse button if this button was pressed inside the widget. void onMouseReleased(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)

call_mouse_wheel_fn(self: omni.ui._ui.Widget, arg0: float, arg1: float, arg2: int) None

Sets the function that will be called when the user uses mouse wheel on the focused window. The function specification is the same as in setMousePressedFn. void onMouseWheel(float x, float y, carb::input::KeyboardModifierFlags modifier)

call_tooltip_fn(self: omni.ui._ui.Widget) None

Set dynamic tooltip that will be created dynamiclly the first time it is needed. the function is called inside a ui.Frame scope that the widget will be parented correctly.

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

Removes all the callbacks and circular references.

has_accept_drop_fn(self: omni.ui._ui.Widget) bool

Specify that this Widget can accept specific drops and set the callback that is called to check if the drop can be accepted.

has_computed_content_size_changed_fn(self: omni.ui._ui.Widget) bool

Called when the size of the widget is changed.

has_drag_fn(self: omni.ui._ui.Widget) bool

Specify that this Widget is draggable, and set the callback that is attached to the drag operation.

has_drop_fn(self: omni.ui._ui.Widget) bool

Specify that this Widget accepts drops and set the callback to the drop operation.

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

Sets the function that will be called when the user presses the keyboard key when the mouse clicks the widget.

has_mouse_double_clicked_fn(self: omni.ui._ui.Widget) bool

Sets the function that will be called when the user presses the mouse button twice inside the widget. The function specification is the same as in setMousePressedFn. void onMouseDoubleClicked(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)

has_mouse_hovered_fn(self: omni.ui._ui.Widget) bool

Sets the function that will be called when the user use mouse enter/leave on the focused window. function specification is the same as in setMouseHovedFn. void onMouseHovered(bool hovered)

has_mouse_moved_fn(self: omni.ui._ui.Widget) bool

Sets the function that will be called when the user moves the mouse inside the widget. Mouse move events only occur if a mouse button is pressed while the mouse is being moved. void onMouseMoved(float x, float y, int32_t modifier)

has_mouse_pressed_fn(self: omni.ui._ui.Widget) bool

Sets the function that will be called when the user presses the mouse button inside the widget. The function should be like this: void onMousePressed(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier) Where ‘button’ is the number of the mouse button pressed. ‘modifier’ is the flag for the keyboard modifier key.

has_mouse_released_fn(self: omni.ui._ui.Widget) bool

Sets the function that will be called when the user releases the mouse button if this button was pressed inside the widget. void onMouseReleased(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)

has_mouse_wheel_fn(self: omni.ui._ui.Widget) bool

Sets the function that will be called when the user uses mouse wheel on the focused window. The function specification is the same as in setMousePressedFn. void onMouseWheel(float x, float y, carb::input::KeyboardModifierFlags modifier)

has_tooltip_fn(self: omni.ui._ui.Widget) bool

Set dynamic tooltip that will be created dynamiclly the first time it is needed. the function is called inside a ui.Frame scope that the widget will be parented correctly.

scroll_here(self: omni.ui._ui.Widget, center_ratio_x: float = 0.0, center_ratio_y: float = 0.0) None

Adjust scrolling amount in two axes to make current item visible.

### Arguments:

`centerRatioX :`

0.0: left, 0.5: center, 1.0: right

`centerRatioY :`

0.0: top, 0.5: center, 1.0: bottom

scroll_here_x(self: omni.ui._ui.Widget, center_ratio: float = 0.0) None

Adjust scrolling amount to make current item visible.

### Arguments:

`centerRatio :`

0.0: left, 0.5: center, 1.0: right

scroll_here_y(self: omni.ui._ui.Widget, center_ratio: float = 0.0) None

Adjust scrolling amount to make current item visible.

### Arguments:

`centerRatio :`

0.0: top, 0.5: center, 1.0: bottom

set_accept_drop_fn(self: omni.ui._ui.Widget, fn: Callable[[str], bool]) None

Specify that this Widget can accept specific drops and set the callback that is called to check if the drop can be accepted.

set_checked_changed_fn(self: omni.ui._ui.Widget, fn: Callable[[bool], None]) None

This property holds a flag that specifies the widget has to use eChecked state of the style. It’s on the Widget level because the button can have sub-widgets that are also should be checked.

set_computed_content_size_changed_fn(self: omni.ui._ui.Widget, fn: Callable[[], None]) None

Called when the size of the widget is changed.

set_drag_fn(self: omni.ui._ui.Widget, fn: Callable[[], str]) None

Specify that this Widget is draggable, and set the callback that is attached to the drag operation.

set_drop_fn(self: omni.ui._ui.Widget, fn: Callable[[omni.ui._ui.WidgetMouseDropEvent], None]) None

Specify that this Widget accepts drops and set the callback to the drop operation.

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

Sets the function that will be called when the user presses the keyboard key when the mouse clicks the widget.

set_mouse_double_clicked_fn(self: omni.ui._ui.Widget, fn: Callable[[float, float, int, int], None]) None

Sets the function that will be called when the user presses the mouse button twice inside the widget. The function specification is the same as in setMousePressedFn. void onMouseDoubleClicked(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)

set_mouse_hovered_fn(self: omni.ui._ui.Widget, fn: Callable[[bool], None]) None

Sets the function that will be called when the user use mouse enter/leave on the focused window. function specification is the same as in setMouseHovedFn. void onMouseHovered(bool hovered)

set_mouse_moved_fn(self: omni.ui._ui.Widget, fn: Callable[[float, float, int, bool], None]) None

Sets the function that will be called when the user moves the mouse inside the widget. Mouse move events only occur if a mouse button is pressed while the mouse is being moved. void onMouseMoved(float x, float y, int32_t modifier)

set_mouse_pressed_fn(self: omni.ui._ui.Widget, fn: Callable[[float, float, int, int], None]) None

Sets the function that will be called when the user presses the mouse button inside the widget. The function should be like this: void onMousePressed(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier) Where ‘button’ is the number of the mouse button pressed. ‘modifier’ is the flag for the keyboard modifier key.

set_mouse_released_fn(self: omni.ui._ui.Widget, fn: Callable[[float, float, int, int], None]) None

Sets the function that will be called when the user releases the mouse button if this button was pressed inside the widget. void onMouseReleased(float x, float y, int32_t button, carb::input::KeyboardModifierFlags modifier)

set_mouse_wheel_fn(self: omni.ui._ui.Widget, fn: Callable[[float, float, int], None]) None

Sets the function that will be called when the user uses mouse wheel on the focused window. The function specification is the same as in setMousePressedFn. void onMouseWheel(float x, float y, carb::input::KeyboardModifierFlags modifier)

set_style(self: omni.ui._ui.Widget, arg0: handle) None

Set the current style. The style contains a description of customizations to the widget’s style.

set_tooltip(self: omni.ui._ui.Widget, tooltip_label: str) None

Set a basic tooltip for the widget, this will simply be a Label, it will follow the Tooltip style

set_tooltip_fn(self: omni.ui._ui.Widget, fn: Callable[[], None]) None

Set dynamic tooltip that will be created dynamiclly the first time it is needed. the function is called inside a ui.Frame scope that the widget will be parented correctly.

property checked

This property holds a flag that specifies the widget has to use eChecked state of the style. It’s on the Widget level because the button can have sub-widgets that are also should be checked.

property computed_content_height

Returns the final computed height of the content of the widget. It’s in puplic section. For the explanation why please see the draw() method.

property computed_content_width

Returns the final computed width of the content of the widget. It’s in puplic section. For the explanation why please see the draw() method.

property computed_height

Returns the final computed height of the widget. It includes margins. It’s in puplic section. For the explanation why please see the draw() method.

property computed_width

Returns the final computed width of the widget. It includes margins. It’s in puplic section. For the explanation why please see the draw() method.

property dragging

This property holds if the widget is being dragged.

property enabled

This property holds whether the widget is enabled. In general an enabled widget handles keyboard and mouse events; a disabled widget does not. And widgets display themselves differently when they are disabled.

property height

This property holds the height of the widget relative to its parent. Do not use this function to find the height of a screen.

property identifier

An optional identifier of the widget we can use to refer to it in queries.

property name

The name of the widget that user can set.

property opaque_for_mouse_events

If the widgets has callback functions it will by default not capture the events if it is the top most widget and setup this option to true, so they don’t get routed to the child widgets either

property screen_position_x

Returns the X Screen coordinate the widget was last draw. This is in Screen Pixel size. It’s a float because we need negative numbers and precise position considering DPI scale factor.

property screen_position_y

Returns the Y Screen coordinate the widget was last draw. This is in Screen Pixel size. It’s a float because we need negative numbers and precise position considering DPI scale factor.

property scroll_only_window_hovered

When it’s false, the scroll callback is called even if other window is hovered.

property selected

This property holds a flag that specifies the widget has to use eSelected state of the style.

property skip_draw_when_clipped

The flag that specifies if it’s necessary to bypass the whole draw cycle if the bounding box is clipped with a scrolling frame. It’s needed to avoid the limitation of 65535 primitives in a single draw list.

property style

The local style. When the user calls setStyle()

property style_type_name_override

By default, we use typeName to look up the style. But sometimes it’s necessary to use a custom name. For example, when a widget is a part of another widget. (Label is a part of Button) This property can override the name to use in style.

property tooltip

Set a basic tooltip for the widget, this will simply be a Label, it will follow the Tooltip style

property tooltip_offset_x

Set the X tooltip offset in points. In a normal state, the tooltip position is linked to the mouse position. If the tooltip offset is non zero, the top left corner of the tooltip is linked to the top left corner of the widget, and this property defines the relative position the tooltip should be shown.

property tooltip_offset_y

Set the Y tooltip offset in points. In a normal state, the tooltip position is linked to the mouse position. If the tooltip offset is non zero, the top left corner of the tooltip is linked to the top left corner of the widget, and this property defines the relative position the tooltip should be shown.

property visible

This property holds whether the widget is visible.

property visible_max

If the current zoom factor and DPI is bigger than this value, the widget is not visible.

property visible_min

If the current zoom factor and DPI is less than this value, the widget is not visible.

property width

This property holds the width of the widget relative to its parent. Do not use this function to find the width of a screen.