Class MenuBar
- class ooodev.gui.menu.MenuBar(component, *, lo_inst=None)[source]
Bases:
_MenuBar
,MenuBarPartial
,ServiceInfoPartial
,LoInstPropsPartial
,MenuEvents
Class for managing MenuBar Component.
See also
- Parameters:
component (Any) –
- __init__(component, *, lo_inst=None)[source]
Constructor
- Parameters:
component (UnoControlDialog) – UNO Component that supports com.sun.star.awt.MenuBar` service.
lo_inst (LoInst, optional) – LoInst, Defaults to
Lo.current_lo
.
- Return type:
None
- add_event_item_activated(cb)
Adds a listener for an event.
Event is invoked when a key has been pressed.
The callback
EventArgs.event_data
will contain a UNOcom.sun.star.awt.MenuEvent
struct.- Return type:
None
- Parameters:
cb (Any) –
- add_event_item_deactivated(cb)
Adds a listener for an event.
Event is invoked when a key has been pressed.
The callback
EventArgs.event_data
will contain a UNOcom.sun.star.awt.MenuEvent
struct.- Return type:
None
- Parameters:
cb (Any) –
- add_event_item_highlighted(cb)
Adds a listener for an event.
Event is invoked when a key has been pressed.
The callback
EventArgs.event_data
will contain a UNOcom.sun.star.awt.MenuEvent
struct.- Return type:
None
- Parameters:
cb (Any) –
- add_event_item_selected(cb)
Adds a listener for an event.
Event is invoked when a key has been pressed.
The callback
EventArgs.event_data
will contain a UNOcom.sun.star.awt.MenuEvent
struct.- Return type:
None
- Parameters:
cb (Any) –
- add_event_menu_events_disposing(cb)
Adds a listener for an event.
Event is invoked when the broadcaster is about to be disposed.
The callback
EventArgs.event_data
will contain a UNOcom.sun.star.lang.EventObject
struct.- Return type:
None
- Parameters:
cb (Any) –
- add_menu_listener(listener)
adds the specified menu listener to receive events from this menu.
- Return type:
None
- Parameters:
listener (com.sun.star.awt.XMenuListener) –
- clear()
Removes all items from the menu.
- Return type:
None
- enable_auto_mnemonics(enable)
Specifies whether mnemonics are automatically assigned to menu items, or not.
- Return type:
None
- Parameters:
enable (bool) –
- enable_item(menu_id, enable=False)
Enables or disables the menu item.
- Parameters:
menu_id (int) – The ID of the menu item.
enable (bool, optional) – The state of the menu item. Defaults to
False
.
- Return type:
None
- execute_cmd(menu_id, in_thread=False)
Executes a command.
- Parameters:
cmd (str) – Command to execute.
menu_id (int) –
in_thread (bool) –
- Return type:
bool
- find_item_menu_id(cmd, search_sub_menu=False)
Find item menu id by command.
- Parameters:
cmd (str) – A menu command such as
.uno:Copy
.search_sub_menu (bool) –
- Returns:
The id of the menu item. If not found, return -1.
- Return type:
int
Note
This is a cached method. If the menu is modified, the cache should be cleared by calling
clear_cache()
.See also
- find_item_pos(cmd, search_sub_menu=False)
Find item position by command.
- Parameters:
cmd (str) – A menu command such as
.uno:Copy
.search_sub_menu (bool) –
- Returns:
- The position of the menu item and the Popup Menu that command was found in.
If
search_sub_menu
isFalse
then the Popup Menu will be None. If not found, return(-1, None)
.
- Return type:
Tuple[int, PopupMenu | None]
Note
This is a cached method. If the menu is modified, the cache should be cleared by calling
clear_cache()
.See also
- classmethod from_lo(lo_inst=None)[source]
Creates a new instance from Lo.
- Parameters:
lo_inst (LoInst, optional) – LoInst, Defaults to
Lo.current_lo
.- Returns:
The instance.
- Return type:
- get_command(menu_id)
Gets the command string for the menu item.
- Return type:
str
- Parameters:
menu_id (int) –
- get_help_command(menu_id)
Gets the help command string for the menu item.
- Return type:
str
- Parameters:
menu_id (int) –
- get_help_text(menu_id)
Gets the help text for the menu item.
- Return type:
str
- Parameters:
menu_id (int) –
- get_implementation_name()
Provides the implementation name of the service implementation.
- Return type:
str
- get_item_count()
Gets the number of items in the menu.
- Return type:
int
- get_item_id(item_pos)
Gets the ID of the item at the specified position.
- Return type:
int
- Parameters:
item_pos (int) –
- get_item_pos(menu_id)
Gets the position of the item with the specified ID.
- Return type:
int
- Parameters:
menu_id (int) –
- get_item_text(menu_id)
returns the string for the given item id.
- Return type:
str
- Parameters:
menu_id (int) –
- get_item_type(item_pos)
Gets the type of the menu item.
- Parameters:
item_pos (int) – The position of the menu item.
- Returns:
The type of the menu item.
- Return type:
MenuItemType
Hint
MenuItemType
is an enum and can be imported fromooo.dyn.awt.menu_item_type
.
- get_max_menu_id()
Gets the maximum menu id.
- Returns:
The maximum menu id.
- Return type:
int
Note
This is a cached method. If the menu is modified, the cache should be cleared by calling
clear_cache()
.
- get_popup_menu(menu_id)
Gets the popup menu from the menu item.
- Parameters:
menu_id (int) – Menu item id.
- Returns:
PopupMenu
instance if found, otherwiseNone
.- Return type:
- get_supported_service_names()
Provides the supported service names of the implementation, including also indirect service names.
- Return type:
Tuple
[str
,...
]
- get_tip_help_text(item_id)
retrieves the tip help text for the menu item.
- Return type:
str
- Parameters:
item_id (int) –
- hide_disabled_entries(hide=True)
Specifies whether disabled menu entries should be hidden, or not.
- Parameters:
hide (bool, optional) –
True
to hide disabled entries,False
to show them. Defaults toTrue
.- Return type:
None
- insert_item(menu_id, text, item_style, item_pos)
Inserts an item into the menu.
The item is appended if the position is greater than or equal to
get_item_count()
or if it is negative.- Parameters:
menu_id (int) – The ID of the menu item.
text (str) – The text for the menu item.
item_style (int | MenuItemStyleKind) – The style of the menu item.
MenuItemStyleKind
is a flag enum.item_pos (int) – The position of the menu item.
- Return type:
None
Hint
MenuItemStyleKind
is an enum and can be imported fromooodev.utils.kind.menu_item_style_kind
.
- is_item_enabled(menu_id)
Gets the state of the menu item.
- Return type:
bool
- Parameters:
menu_id (int) –
- is_popup_menu()
Checks whether an
XMenu
is anXPopupMenu
.- Return type:
bool
- remove_event_item_activated(cb)
Removes a listener for an event
- Return type:
None
- Parameters:
cb (Any) –
- remove_event_item_deactivated(cb)
Removes a listener for an event
- Return type:
None
- Parameters:
cb (Any) –
- remove_event_item_highlighted(cb)
Removes a listener for an event
- Return type:
None
- Parameters:
cb (Any) –
- remove_event_item_selected(cb)
Removes a listener for an event
- Return type:
None
- Parameters:
cb (Any) –
- remove_event_menu_events_disposing(cb)
Removes a listener for an event
- Return type:
None
- Parameters:
cb (Any) –
- remove_item(item_pos, count)
Removes one or more items from the menu.
- Return type:
None
- Parameters:
item_pos (int) –
count (int) –
- remove_menu_listener(listener)
Removes the specified menu listener so that it no longer receives events from this menu.
- Return type:
None
- Parameters:
listener (com.sun.star.awt.XMenuListener) –
- set_command(menu_id, command)
Sets the command string for the menu item.
- Return type:
None
- Parameters:
menu_id (int) –
command (str) –
- set_help_command(menu_id, command)
Sets the help command string for the menu item.
- Return type:
None
- Parameters:
menu_id (int) –
command (str) –
- set_help_text(menu_id, text)
Sets the help text for the menu item.
- Return type:
None
- Parameters:
menu_id (int) –
text (str) –
- set_item_text(menu_id, text)
Sets the text for the menu item.
- Return type:
None
- Parameters:
menu_id (int) –
text (str) –
- set_popup_menu(menu_id, popup_menu)
Sets the popup menu for a specified menu item.
- Return type:
None
- Parameters:
menu_id (int) –
popup_menu (com.sun.star.awt.XPopupMenu) –
- set_tip_help_text(menu_id, text)
Sets the tip help text for the menu item.
- Return type:
None
- Parameters:
menu_id (int) –
text (str) –
- set_visible(visible=True)
Sets the visibility of the menu bar.
- Parameters:
visible (bool, optional) – Visibility. Defaults to
True
.- Return type:
None
- subscribe_all_item_activated(cb)
Adds a callbacks for the item activated event for all menu and submenus items.
- subscribe_all_item_deactivated(cb)
Adds a callbacks for the item deactivated event for all menu and submenus items.
- subscribe_all_item_highlighted(cb)
Adds a callbacks for the item highlighted event for all menu and submenus items.
- subscribe_all_item_selected(cb)
Adds a callbacks for the item selected event for all menu and submenus items.
- supports_all_services(*name)
Tests whether all the specified services are supported, i.e.
- Parameters:
name (str) – One or more service name(s) to test such as
com.sun.star.awt.MenuBar
.- Raises:
ValueError – If no service name is provided.
- Returns:
True
if all the specified services are supported; Otherwise,False
.- Return type:
bool
- supports_service(*name)
Tests whether any of the specified service(s) are supported.
- Parameters:
name (str) – One or more service name(s) to test such as
com.sun.star.awt.MenuBar
.- Returns:
True
if any of the specified service(s) are supported; Otherwise,False
.- Return type:
bool
- toggle_visible()
Toggles the visibility of the menu bar using a dispatch command.
- Return type:
None
- unsubscribe_all_item_activated(cb)
Remove callbacks for the item selected event for all menu and submenus items.
- unsubscribe_all_item_deactivated(cb)
Remove callbacks for the item deactivated event for all menu and submenus items.
- unsubscribe_all_item_highlighted(cb)
Remove callbacks for the item highlighted event for all menu and submenus items.
- unsubscribe_all_item_selected(cb)
Remove callbacks for the item selected event for all menu and submenus items.
- NODE = 'private:resource/menubar/menubar'
- property component: com.sun.star.awt.MenuBar
MenuBar Component
- Return type:
MenuBar
- property events_listener_menu: MenuListener
Returns listener
- Return type: