WebPage
Superclasses: Object
A loaded web page.
Methods
- class WebPage
-
- get_form_manager(world: ScriptWorld | None = None) WebFormManager
Get the
WebFormManager
ofweb_page
inworld
.Added in version 2.40.
- Parameters:
world – a
ScriptWorld
- get_uri() str
Returns the current active URI of
web_page
.You can monitor the active URI by connecting to the notify::uri signal of
web_page
.
- send_message_to_view(message: UserMessage, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None
Send
message
to theWebKitWebView
corresponding toweb_page
. Ifmessage
is floating, it’s consumed.If you don’t expect any reply, or you simply want to ignore it, you can pass
None
ascallback
. When the operation is finished,callback
will be called. You can then callsend_message_to_view_finish()
to get the message reply.Added in version 2.28.
- Parameters:
message – a
UserMessage
cancellable – a
Cancellable
orNone
to ignorecallback – A
AsyncReadyCallback
to call when the request is satisfied orNone
user_data – the data to pass to callback function
- send_message_to_view_finish(result: AsyncResult) UserMessage
Finish an asynchronous operation started with
send_message_to_view()
.Added in version 2.28.
- Parameters:
result – a
AsyncResult
Properties
Signals
- class WebPage.signals
Emitted before a context menu is displayed in the UI Process to give the application a chance to customize the proposed menu, build its own context menu or pass user data to the UI Process. This signal is useful when the information available in the UI Process is not enough to build or customize the context menu, for example, to add menu entries depending on the node at the coordinates of the
hit_test_result
. Otherwise, it’s recommended to useWebKitWebView
::context-menu signal instead.Added in version 2.8.
- Parameters:
context_menu – the proposed
ContextMenu
hit_test_result – a
WebHitTestResult
- document_loaded() None
This signal is emitted when the DOM document of a
WebPage
has been loaded.You can wait for this signal to get the DOM document
- send_request(request: URIRequest, redirected_response: URIResponse) bool
This signal is emitted when
request
is about to be sent to the server. This signal can be used to modify theURIRequest
that will be sent to the server. You can also cancel the resource load operation by connecting to this signal and returningTrue
.In case of a server redirection this signal is emitted again with the
request
argument containing the new request to be sent to the server due to the redirection and theredirected_response
parameter containing the response received by the server for the initial request.Modifications to the
URIRequest
and its associatedMessageHeaders
will be taken into account when the request is sent over the network.- Parameters:
request – a
URIRequest
redirected_response – a
URIResponse
, orNone
- user_message_received(message: UserMessage) bool
This signal is emitted when a
UserMessage
is received from theWebKitWebView
corresponding toweb_page
. You can reply to the message usingsend_reply()
.You can handle the user message asynchronously by calling
ref()
onmessage
and returningTrue
. If the last reference ofmessage
is removed and the message has been replied, the operation in theWebKitWebView
will finish with errorUSER_MESSAGE_UNHANDLED_MESSAGE
.Added in version 2.28.
- Parameters:
message – the
UserMessage
received