OptionMenu#
Added in version 2.18.
Superclasses: Object
Represents the dropdown menu of a select
element in a WebView
.
When a select element in a WebView
needs to display a dropdown menu, the signal
WebView
::show-option-menu is emitted, providing a WebKitOptionMenu with the
OptionMenuItem
<!– –>s that should be displayed.
Methods#
- class OptionMenu
- activate_item(index: int) → None#
Activates the
OptionMenuItem
atindex
inmenu
.Activating an item changes the value of the element making the item the active one. You are expected to close the menu with
close()
after activating an item, calling this function again will have no effect.Added in version 2.18.
- Parameters:
index – the index of the item
- close() → None#
Request to close a
OptionMenu
.This emits WebKitOptionMenu::close signal. This function should always be called to notify WebKit that the associated menu has been closed. If the menu is closed and neither
select_item()
noractivate_item()
have been called, the element value remains unchanged.Added in version 2.18.
- get_event() → Event#
Gets the
Event
that triggered the dropdown menu. Ifmenu
was not triggered by a user interaction, like a mouse click,None
is returned.Added in version 2.40.
- get_item(index: int) → OptionMenuItem#
Returns the
OptionMenuItem
atindex
inmenu
.Added in version 2.18.
- Parameters:
index – the index of the item
- select_item(index: int) → None#
Selects the
OptionMenuItem
atindex
inmenu
.Selecting an item changes the text shown by the combo button, but it doesn’t change the value of the element. You need to explicitly activate the item with
select_item()
or close the menu withclose()
in which case the currently selected item will be activated.Added in version 2.18.
- Parameters:
index – the index of the item
Signals#
- class OptionMenu.signals
- close() → None#
Emitted when closing a
OptionMenu
is requested. This can happen when the user explicitly callsclose()
or when the element is detached from the current page.Added in version 2.18.