ContextMenuWidgetExtension
- class omni.kit.widget.context_menu.context_menu.ContextMenuWidgetExtension
Bases:
IExt
Context menu core functionality
Methods
__init__
()ContextMenuWidgetExtension init function.
Close currently open context menu.
Gets current context_menu.
menu
(name[, delegate, glyph, submenu, tearable])Creates a menu.
menu_item
(name[, triggered_fn, enabled, ...])Creates a menu item.
ContextMenuWidgetExtension shutdown function.
on_startup
(ext_id)ContextMenuWidgetExtension startup function.
separator
([name])Creates a menu separator.
show_context_menu
(menu_name, objects, menu_list)build context menu from menu_list
Attributes
Name of current context menu.
- __init__()
ContextMenuWidgetExtension init function.
- close_menu()
Close currently open context menu. Used by tests not to leave context menu in bad state.
- get_context_menu()
Gets current context_menu.
- Returns
Current context_menu.
- Return type
(str)
- menu(name: str, delegate=None, glyph='', submenu=False, tearable=False, **kwargs)
Creates a menu.
- Parameters
name (str) – Name of the menu.
delegate (ui.MenuDelegate) – Specify the delegate to create a custom menu. Optional.
glyph (str) – Path of the glyph image to show before the menu name. Optional.
submenu (bool) – Enables the submenu marker. Optional.
tearable (bool) – The ability to tear the window off. Optional.
- Returns
Menu item created.
- Return type
(uiMenu)
- menu_item(name: str, triggered_fn: Optional[Callable] = None, enabled: bool = True, checkable: bool = False, checked: bool = False, is_async_func=False, delegate=None, additional_kwargs=None, glyph='')
Creates a menu item.
- Parameters
name (str) – Name of the menu item.
triggered_fn (Callable) – Function to call when menu item is clicked. Optional.
enabled (bool) – Enable the menu item. Optional.
checkable (bool) – This property holds whether this menu item is checkable. A checkable item is one which has an on/off state. Optional.
checked (bool) – 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. Optional.
is_async_func (bool) – Optional.
delegate (ui.MenuDelegate) – Specify the delegate to create a custom menu. Optional.
additional_kwargs (dict) – Additional keyword arguments to pass to ui.MenuItem. Optional.
glyph (str) – Path of the glyph image to show before the menu name. Optional.
- Returns
Menu item created.
- Return type
(uiMenuItem)
- on_shutdown()
ContextMenuWidgetExtension shutdown function.
- on_startup(ext_id)
ContextMenuWidgetExtension startup function.
- Parameters
ext_id (str) – Extension identifier.
- separator(name: str = '') → bool
Creates a menu separator.
- Parameters
name (str) – Name of the menu separator. Optional.
- show_context_menu(menu_name: str, objects: dict, menu_list: List[dict], min_menu_entries: int = 1, delegate=None) → None
build context menu from menu_list
- Parameters
menu_name (str) – menu name
objects (dict) – context_menu data
menu_list (list) – list of dictionaries containing context menu values
min_menu_entries (int) – minimal number of menu needed for menu to be visible
- property name: str
Name of current context menu.
- Returns
Name of current context menu.
- Return type
(str)