OptionItem#

class omni.kit.widget.options_menu.OptionItem(
name: str | None,
text: str | None = None,
default: bool = False,
on_value_changed_fn: Callable[[bool], None] | None = None,
model: SimpleBoolModel | None = None,
setting_path: str | None = None,
enabled: bool = True,
checkable: bool = True,
hide_on_click: bool = False,
)#

Bases: AbstractOptionItem

Represents a general item for OptionsMenu.

Parameters:
  • name (str) – The name of the menu item.

  • text (str) – The text to display for the menu item. Defaults to the name if not provided.

  • default (bool) – The initial value of the item. Defaults to False.

  • on_value_changed_fn (Callable[[bool], None]) – A callback function that is called when the item’s value changes.

  • model (Optional[ui.SimpleBoolModel]) – The model associated with the item. If not provided, a new model is created.

  • setting_path (Optional[str]) – The path used to store the item’s setting. If not provided, no setting is stored.

  • enabled (bool) – Indicates whether the menu item is enabled. Defaults to True.

  • checkable (bool) – Determines if the menu item can be checked. Defaults to True.

  • hide_on_click (bool) – Determines if the menu item should hide when clicked. Defaults to False.

Methods

__init__(name[, text, default, ...])

Constructor for OptionItem.

build_custom_widget(item)

Builds a custom widget for the associated menu item.

build_menu_item(**kwargs)

Builds the associated menu item with the given keyword arguments.

destroy()

Cleans up any resources held by the item.

on_triggered()

Executes the action associated with the item when it is triggered.

reset()

Resets the option item's value to its default state.

Attributes

dirty

Gets the dirty state indicating if the item's value has changed.

enabled

Gets the enabled state of the option item.

model

Gets the value model of the option item.

value

Gets the current value of the option item.

__init__(
name: str | None,
text: str | None = None,
default: bool = False,
on_value_changed_fn: Callable[[bool], None] | None = None,
model: SimpleBoolModel | None = None,
setting_path: str | None = None,
enabled: bool = True,
checkable: bool = True,
hide_on_click: bool = False,
)#

Constructor for OptionItem.

build_custom_widget(item: MenuItem) None#

Builds a custom widget for the associated menu item.

Parameters:

item (ui.MenuItem) – The menu item associated with this option.

build_menu_item(**kwargs) None#

Builds the associated menu item with the given keyword arguments.

Keyword Arguments:

enabled (bool) – If the menu item is enabled.

destroy()#

Cleans up any resources held by the item.

on_triggered()#

Executes the action associated with the item when it is triggered.

reset() None#

Resets the option item’s value to its default state.

property dirty: bool#

Gets the dirty state indicating if the item’s value has changed.

Returns:

The current dirty state.

Return type:

bool

property enabled: bool#

Gets the enabled state of the option item.

Returns:

The current enabled state.

Return type:

bool

property model: SimpleBoolModel#

Gets the value model of the option item.

Returns:

The current value model.

Return type:

ui.SimpleBoolModel

property value: bool#

Gets the current value of the option item.

Returns:

The current value.

Return type:

bool