ContextMenuItem#
Superclasses: InitiallyUnowned, Object
One item of a ContextMenu.
The ContextMenu is composed of ContextMenuItem<!–
–>s. These items can be created from a GtkAction, from a
ContextMenuAction or from a ContextMenuAction and a
label. These ContextMenuAction<!– –>s denote stock actions
for the items. You can also create separators and submenus.
Constructors#
- class ContextMenuItem
- classmethod new_from_gaction(action: Action, label: str, target: Variant | None = None) → ContextMenuItem#
Creates a new
ContextMenuItemfor the givenactionandlabel.On activation
targetwill be passed as parameter to the callback.Added in version 2.18.
- classmethod new_from_stock_action(action: ContextMenuAction) → ContextMenuItem#
Creates a new
ContextMenuItemfor the given stock action.Stock actions are handled automatically by WebKit so that, for example, when a menu item created with a
STOPis activated the action associated will be handled by WebKit and the current load operation will be stopped. You can get theActionof aContextMenuItemcreated with aContextMenuActionwithget_gaction()and connect to theSimpleAction::activate signal to be notified when the item is activated, but you can’t prevent the associated action from being performed.- Parameters:
action – a
ContextMenuActionstock action
- classmethod new_from_stock_action_with_label(action: ContextMenuAction, label: str) → ContextMenuItem#
Creates a new
ContextMenuItemfor the given stock action using the givenlabel.Stock actions have a predefined label, this method can be used to create a
ContextMenuItemfor aContextMenuActionbut using a custom label.- Parameters:
action – a
ContextMenuActionstock actionlabel – a custom label text to use instead of the predefined one
- classmethod new_separator() → ContextMenuItem#
Creates a new
ContextMenuItemrepresenting a separator.
- classmethod new_with_submenu(label: str, submenu: ContextMenu) → ContextMenuItem#
Creates a new
ContextMenuItemusing the givenlabelwith a submenu.- Parameters:
label – the menu item label text
submenu – a
ContextMenuto set
Methods#
- class ContextMenuItem
-
- get_stock_action() → ContextMenuAction#
Gets the
ContextMenuActionofitem.If the
ContextMenuItemwas not created for a stock actionCUSTOMwill be returned. If theContextMenuItemis a separatorNO_ACTIONwill be returned.
- get_submenu() → ContextMenu#
Gets the submenu of
item.
- set_submenu(submenu: ContextMenu | None = None) → None#
Sets or replaces the
itemsubmenu.If
submenuisNonethe current submenu ofitemis removed.- Parameters:
submenu – a
ContextMenu