ViewportMenuDelegate#

class omni.kit.viewport.menubar.core.ViewportMenuDelegate(
icon_name: str = '',
icon_width: int = 16,
reserve_status: bool = True,
force_checked: bool = False,
icon_clicked_fn: Callable[[None], None] | None = None,
build_custom_widgets: Callable[[MenuDelegate, MenuItem | Menu], None] | None = None,
show_hotkey_placeholder: bool = False,
)#

Bases: MenuDelegate

A basic menu delegate within a viewport menubar

Methods

__init__([icon_name, icon_width, ...])

Constructor.

build_item(item)

Build widgets (from left to right):

get_checked()

Delegate checked state

get_selected()

Delegate selected state

set_checked(value)

Set delegate checked state and return whether it changed or not.

set_selected(value)

Set delegate selected state and return whether it changed or not.

Attributes

checked

Delegate checked state

selected

Delegate selected state

__init__(
icon_name: str = '',
icon_width: int = 16,
reserve_status: bool = True,
force_checked: bool = False,
icon_clicked_fn: Callable[[None], None] | None = None,
build_custom_widgets: Callable[[MenuDelegate, MenuItem | Menu], None] | None = None,
show_hotkey_placeholder: bool = False,
)#

Constructor.

Keyword Arguments:
  • icon_name (str) – Name of icon to show after menu text, defaults to “” means no icon.

  • icon_width (int) – Icon width, defaults to 16 pixels.

  • reserve_status (bool) – Show additional space before widgets, defaults to False. Used to align with other menu items which have status icon.

  • force_checked (bool) – Force to show checked status, defaults to False. It is strange that when a menu is checked, sub menu items checked flag will be cleared. Use this flag to show correct sub menu item status.

  • icon_clicked_fn (Callable[[None], None]) – Callback when icon clicked, defaults to None

  • build_custom_widgets (Callable[[ui.MenuDelegate, Union[ui.MenuItem, ui.Menu]], None]) – Callback to build custom widgets, defaults to None.

  • show_hotkey_placeholder (bool) – Show placeholder for hotkey text, defaults to False. Used to align with other menu items which have hotkeys.

build_item(
item: MenuItem | Menu,
) None#
Build widgets (from left to right):
  • Selected icon

  • Menu item label

  • Menu item Icon

  • Custom widgets (Optional)

  • Hotkey label

  • Arrow for sub menus (only for ui.Menu)

Parameters:
  • Union[ui.MenuItem (item) – Menu item.

  • ui.Menu]) – Menu item.

get_checked() bool#

Delegate checked state

get_selected() bool#

Delegate selected state

set_checked(value: bool) bool#

Set delegate checked state and return whether it changed or not.

set_selected(value: bool) bool#

Set delegate selected state and return whether it changed or not.

property checked: bool#

Delegate checked state

property selected: bool#

Delegate selected state