.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.html2.WebView:

==========================================================================================================================================
|phoenix_title|  **wx.html2.WebView**
==========================================================================================================================================

This control may be used to render web (HTML / CSS / JavaScript) documents. 
         

It is designed to allow the creation of multiple backends for each port. It differs from :ref:`wx.html.HtmlWindow`  in that each backend is actually a full web engine, provided by a 3rd party (e.g., WebView2 on MSW or WebKit on macOS and GTK). This allows the correct viewing of complex pages with JavaScript and CSS. 



|phoenix_title| Backend Descriptions
====================================

This class supports using multiple backends, corresponding to different implementations of the same functionality. WebViewChrome is available on all three major platforms and each platform also has its own default native backend. Backends are identified by their names, documented in the backend descriptions below. 

|phoenix_title| ``WEBVIEW_BACKEND_IE`` (MSW)
============================================

The IE backend uses Microsoft's `WebBrowser <http://msdn.microsoft.com/en-us/library/aa752085%28v=VS.85%29.aspx>`_  control, which depends the locally installed version of Internet Explorer. By default this backend emulates Internet Explorer 7. This can be changed with a registry setting by :meth:`WebViewIE.MSWSetEmulationLevel`   see `this <http://msdn.microsoft.com/en-us/library/ee330730%28v=vs.85%29.aspx#browser_emulation>`_  article for more information. This backend has full support for custom schemes and virtual file systems. The predefined  ``WebViewBackendIE``   constant contains the name of this backend and can be used to explicitly select it when using  :meth:`wx.html2.WebView.New` .  

|phoenix_title| ``WEBVIEW_BACKEND_EDGE`` (MSW)
==============================================

The Edge backend uses Microsoft's `Edge WebView2 <https://docs.microsoft.com/en-us/microsoft-edge/hosting/webview2>`_. It is available for Windows 7 (newer versions require Windows ``10+``) and newer. This backend does not support custom schemes. When using handlers, see :meth:`wx.html2.WebViewHandler.SetVirtualHost`   for more details on how to access handler provided URLs. This backend is enabled by default only when using CMake. To build it follow these steps:

- When not using CMake:

  - Download the `WebView2 SDK <https://aka.ms/webviewnuget>`_  NuGet package (Version 1.0.864.35 or newer) 
  - Extract the package (it's a zip archive) to  ``WX_SRCDIR/3rdparty/webview2``   (you should have   ``3rdparty/webview2/build/native/include/WebView2.h``   file after unpacking it) 
  - Enable  ``USE_WEBVIEW_EDGE``   in   ``setup.h``       



- When using CMake, the backend is enabled by default. It can be disabled by setting  ``USE_WEBVIEW_EDGE``   to   ``OFF`` . If a WebView2 ``SDK`` is found in   ``WX_SRCDIR/3rdparty/webview2``   (see the bullet above), that ``SDK`` is used. Otherwise, the ``SDK`` is downloaded and extracted by CMake during the configure phase (into directory   ``WX_BUILDDIR/libs/webview/packages`` ) 
- Build wxWidgets webview library 
- From the WebView2 ``SDK``  ``build``   subdirectory copy   ``WebView2Loader.dll``   corresponding to the architecture used (x86 or x64) to the directory with your application executable 
- At runtime you can use :meth:`wx.html2.WebView.IsBackendAvailable`   to check if the backend can be used (it will be available if  ``WebView2Loader.dll``   can be loaded and Edge (Chromium) is installed) 
- Make sure to add a note about using the WebView2 ``SDK`` to your application documentation, as required by its licence 
- With Visual Studio 2019 or newer  ``USE_WEBVIEW_EDGE_STATIC``   can be used to static link the loader and remove the dependency on   ``WebView2Loader.dll``   at runtime. 


If enabled and available at runtime, Edge will be selected as the default backend. If you require the IE backend use  ``WebViewBackendIE``   when using  :meth:`wx.html2.WebView.New` . If your application should use a `fixed version <https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#fixed-version-distribution-mode>`_  of the WebView2 runtime you must use :meth:`WebViewEdge.MSWSetBrowserExecutableDir`   to specify its usage before using the Edge backend. The predefined  ``WebViewBackendEdge``   constant contains the name of this backend.  

|phoenix_title| ``WEBVIEW_WEBKIT`` (GTK)
========================================

Under GTK the WebKit backend uses `WebKitGTK+ <http://webkitgtk.org/>`_. The current minimum version required is 1.3.1 which ships by default with Ubuntu Natty and Debian Wheezy and has the package name libwebkitgtk-dev. Custom schemes and virtual files systems are supported under this backend, however embedded resources such as images and stylesheets are currently loaded using the data:// scheme. The predefined  ``WebViewBackendWebKit``   constant contains the name of this backend.  

|phoenix_title| ``WEBVIEW_WEBKIT2`` (``GTK3``)
==============================================

Under ``GTK3`` the WebKit2 version of `WebKitGTK+ <http://webkitgtk.org/>`_  is used. In Ubuntu the required package name is libwebkit2gtk-4.0-dev and under Fedora it is webkitgtk4-devel. All features are supported except for clearing and enabling / disabling the history. The predefined  ``WebViewBackendWebKit``   constant contains the name of this backend.  

|phoenix_title| ``WEBVIEW_WEBKIT`` (macOS)
==========================================

The macOS WebKit backend uses Apple's `WKWebView <https://developer.apple.com/documentation/webkit/wkwebview>`_  class. This backend has full support for custom schemes and virtual file systems on macOS 10.13+. In order to use handlers, two-step creation has to be used and :meth:`~wx.html2.WebView.RegisterHandler`  has to be called before :meth:`~wx.html2.WebView.Create`. Starting with macOS 10.11 and iOS 9 an application cannot create unsecure connections (this includes ``HTTP`` and unverified ``HTTPS``). You have to include additional fields in your Info.plist to enable such connections. For further details see the documentation on NSAppTransportSecurity `here <https://developer.apple.com/documentation/bundleresources/information_property_list/nsapptransportsecurity>`_ The predefined  ``WebViewBackendWebKit``   constant contains the name of this backend.  

|phoenix_title| ``WEBVIEW_CHROMIUM`` (MSW, macOS, GTK)
======================================================

The Chromium Embedded Framework backend has to be enabled when building wxWidgets, see `WebViewChromium`       for additional usage and build instructions. The predefined  ``WebViewBackendChromium``   constant contains the name of this backend.   



|phoenix_title| Asynchronous Notifications
==========================================

Many of the methods in :ref:`wx.html2.WebView`  are asynchronous, i.e. they return immediately and perform their work in the background. This includes functions such as :meth:`~wx.html2.WebView.LoadURL`  and :meth:`~wx.html2.WebView.Reload`. To receive notification of the progress and completion of these functions you need to handle the events that are provided. Specifically  ``wxEVT_WEBVIEW_LOADED``   notifies when the page or a sub-frame has finished loading and   ``wxEVT_WEBVIEW_ERROR``   notifies that an error has occurred.  



|phoenix_title| Virtual File Systems and Custom Schemes
=======================================================

:ref:`wx.html2.WebView`  supports the registering of custom scheme handlers, for example  ``file``   or   ``http`` . To do this create a new class which inherits from  :ref:`wx.html2.WebViewHandler`, where :meth:`wx.html2.WebViewHandler.GetFile`   returns a pointer to a :ref:`wx.FSFile`  which represents the given url or :meth:`wx.html2.WebViewHandler.StartRequest`   for more complex requests. You can then register your handler with :meth:`~wx.html2.WebView.RegisterHandler`  it will be called for all pages and resources. :ref:`wx.html2.WebViewFSHandler`  is provided to access the virtual file system encapsulated by :ref:`wx.FileSystem`. The :ref:`wx.MemoryFSHandler`  documentation gives an example of how this may be used. :ref:`wx.html2.WebViewArchiveHandler`  is provided to allow the navigation of pages inside a zip archive. It supports paths of the form:  ``scheme:///C:/example/docs.zip;protocol=zip/main.htm``   



.. _WebView-events:

|events| Events Emitted by this Class
=====================================

Handlers bound for the following event types will receive one of the :ref:`wx.html2.WebViewEvent` parameters.

- EVT_WEBVIEW_CREATED: Process a  ``wxEVT_WEBVIEW_CREATED``   event, generated when the object is fully initialized. For the backends using asynchronous initialization, such as  `WebViewChromium`     , most of this class member functions can be only used once this event is received. Available only in wxWidgets 3.3.0 or later.  
- EVT_WEBVIEW_NAVIGATING: Process a  ``wxEVT_WEBVIEW_NAVIGATING``   event, generated before trying to get a resource. This event may be vetoed to prevent navigating to this resource. Note that if the displayed HTML document has several frames, one such event will be generated per frame.   
- EVT_WEBVIEW_NAVIGATED: Process a  ``wxEVT_WEBVIEW_NAVIGATED``   event generated after it was confirmed that a resource would be requested. This event may not be vetoed. Note that if the displayed HTML document has several frames, one such event will be generated per frame.   
- EVT_WEBVIEW_LOADED: Process a  ``wxEVT_WEBVIEW_LOADED``   event generated when the document is fully loaded and displayed. Note that if the displayed HTML document has several frames, one such event will be generated per frame.   
- EVT_WEBVIEW_ERROR: Process a  ``wxEVT_WEBVIEW_ERROR``   event generated when a navigation error occurs. The integer associated with this event will be a WebNavigationError item. The string associated with this event may contain a backend-specific more precise error message/code.   
- EVT_WEBVIEW_NEWWINDOW: Process a  ``wxEVT_WEBVIEW_NEWWINDOW``   event, generated when a new window is created. You must handle this event if you want anything to happen, for example to load the page in a new window or tab. For usage details see  :ref:`wx.html2.WebViewWindowFeatures`.  
- EVT_WEBVIEW_NEWWINDOW_FEATURES: Process a  ``wxEVT_WEBVIEW_NEWWINDOW_FEATURES``   event, generated when window features are available for the new window. For usage details see  :ref:`wx.html2.WebViewWindowFeatures`. Available only in wxWidgets 3.3.0 or later.  
- EVT_WEBVIEW_WINDOW_CLOSE_REQUESTED: Process a  ``wxEVT_WEBVIEW_WINDOW_CLOSE_REQUESTED``   event, generated when a window is requested to be closed. Available only in wxWidgets 3.3.0 or later.   
- EVT_WEBVIEW_TITLE_CHANGED: Process a  ``wxEVT_WEBVIEW_TITLE_CHANGED``   event, generated when the page title changes. Use GetString to get the title.   
- EVT_WEBVIEW_FULLSCREEN_CHANGED: Process a  ``wxEVT_WEBVIEW_FULLSCREEN_CHANGED``   event, generated when the page wants to enter or leave fullscreen. Use GetInt to get the status. Not implemented for the IE backend. Available only in wxWidgets 3.1.5 or later.   
- EVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED: Process a  ``wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED``   event. Available only in wxWidgets 3.1.5 or later. For usage details see  :meth:`~wx.html2.WebView.AddScriptMessageHandler`.  
- EVT_WEBVIEW_SCRIPT_RESULT: Process a  ``wxEVT_WEBVIEW_SCRIPT_RESULT``   event. Available only in wxWidgets 3.1.6 or later. For usage details see  :meth:`~wx.html2.WebView.RunScriptAsync`.  
- wxEVT_WEBVIEW_BROWSING_DATA_CLEARED: Process a  ``wxEVT_WEBVIEW_BROWSING_DATA_CLEARED``   event only available in wxWidgets 3.3.0 or later. For usage details see  :meth:`~wx.html2.WebView.ClearBrowsingData`.  


:ref:`wx.html2.WebView`   



.. versionadded:: 2.9.3 
     







.. note:: 

   If you plan to display any modern web content you should consider using ``WEBVIEW_BACKEND_EDGE`` , as Internet Explorer is not supported anymore by Microsoft.  







.. seealso:: :ref:`wx.html2.WebViewEvent`, :ref:`wx.html2.WebViewConfiguration`, :ref:`wx.html2.WebViewHandler`    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>WebView</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.html2.WebView_inheritance.svg" alt="Inheritance diagram of WebView" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.html2.WebView.html" title="This control may be used to render web (HTML / CSS / JavaScript) documents." alt="" coords="40,313,203,341"/> <area shape="rect" id="node2" href="wx.Control.html" title="This is the base class for a control or 'widget'." alt="" coords="69,236,174,265"/> <area shape="rect" id="node3" href="wx.Window.html" title="wx.Window  is the base class for all windows and represents any visible object on screen." alt="" coords="66,159,177,188"/> <area shape="rect" id="node4" href="wx.EvtHandler.html" title="A class that can handle events from the windowing system." alt="" coords="55,82,188,111"/> <area shape="rect" id="node5" href="wx.Object.html" title="This is the root class of many of the wxWidgets classes." alt="" coords="5,5,104,34"/> <area shape="rect" id="node6" href="wx.Trackable.html" title="Add-on base class for a trackable object." alt="" coords="128,5,251,34"/> </map> 
   </p>
   </div>

|


|sub_classes| Known Subclasses
==============================

`WebViewChromium`     , `WebViewEdge`     , `WebViewIE`     

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.html2.WebView.AddScriptMessageHandler`                                Add a script message handler with the given name.
:meth:`~wx.html2.WebView.AddUserScript`                                          Injects the specified script into the webpage's content.
:meth:`~wx.html2.WebView.AreBrowserAcceleratorKeysEnabled`                       Returns ``True`` if browser accelerator keys are enabled.
:meth:`~wx.html2.WebView.CanCopy`                                                Returns ``True`` if the current selection can be copied.
:meth:`~wx.html2.WebView.CanCut`                                                 Returns ``True`` if the current selection can be cut.
:meth:`~wx.html2.WebView.CanGoBack`                                              Returns ``True`` if it is possible to navigate backward in the history of visited pages.
:meth:`~wx.html2.WebView.CanGoForward`                                           Returns ``True`` if it is possible to navigate forward in the history of visited pages.
:meth:`~wx.html2.WebView.CanPaste`                                               Returns ``True`` if data can be pasted.
:meth:`~wx.html2.WebView.CanRedo`                                                Returns ``True`` if there is an action to redo.
:meth:`~wx.html2.WebView.CanSetZoomType`                                         Retrieve whether a zoom type is supported.
:meth:`~wx.html2.WebView.CanUndo`                                                Returns ``True`` if there is an action to undo.
:meth:`~wx.html2.WebView.ClearBrowsingData`                                      Clears the browsing data of the web view.
:meth:`~wx.html2.WebView.ClearHistory`                                           Clear the history, this will also remove the visible page.
:meth:`~wx.html2.WebView.ClearSelection`                                         Clears the current selection.
:meth:`~wx.html2.WebView.Copy`                                                   Copies the current selection.
:meth:`~wx.html2.WebView.Create`                                                 Creation function for two-step creation.
:meth:`~wx.html2.WebView.Cut`                                                    Cuts the current selection.
:meth:`~wx.html2.WebView.DeleteSelection`                                        Deletes the current selection.
:meth:`~wx.html2.WebView.EnableAccessToDevTools`                                 Enable or disable access to dev tools for the user.
:meth:`~wx.html2.WebView.EnableBrowserAcceleratorKeys`                           Enable or disable if browser accelerator keys are enabled.
:meth:`~wx.html2.WebView.EnableContextMenu`                                      Enable or disable the right click context menu.
:meth:`~wx.html2.WebView.EnableHistory`                                          Enable or disable the history.
:meth:`~wx.html2.WebView.Find`                                                   Finds a phrase on the current page and if found, the control will scroll the phrase into view and select it.
:meth:`~wx.html2.WebView.GetBackwardHistory`                                     Returns a list of items in the back history.
:meth:`~wx.html2.WebView.GetClassDefaultAttributes`                              
:meth:`~wx.html2.WebView.GetCurrentTitle`                                        Get the title of the current web page, or its URL/path if title is not available.
:meth:`~wx.html2.WebView.GetCurrentURL`                                          Get the URL of the currently displayed document.
:meth:`~wx.html2.WebView.GetForwardHistory`                                      Returns a list of items in the forward history.
:meth:`~wx.html2.WebView.GetNativeBackend`                                       Return the pointer to the native backend used by this control.
:meth:`~wx.html2.WebView.GetPageSource`                                          Get the HTML source code of the currently displayed document.
:meth:`~wx.html2.WebView.GetPageText`                                            Get the text of the current page.
:meth:`~wx.html2.WebView.GetSelectedSource`                                      Returns the currently selected source, if any.
:meth:`~wx.html2.WebView.GetSelectedText`                                        Returns the currently selected text, if any.
:meth:`~wx.html2.WebView.GetUserAgent`                                           Returns the current user agent string for the web view.
:meth:`~wx.html2.WebView.GetZoom`                                                Get the zoom level of the page.
:meth:`~wx.html2.WebView.GetZoomFactor`                                          Get the zoom factor of the page.
:meth:`~wx.html2.WebView.GetZoomType`                                            Get how the zoom factor is currently interpreted.
:meth:`~wx.html2.WebView.GoBack`                                                 Navigate back in the history of visited pages.
:meth:`~wx.html2.WebView.GoForward`                                              Navigate forward in the history of visited pages.
:meth:`~wx.html2.WebView.HasSelection`                                           Returns ``True`` if there is a current selection.
:meth:`~wx.html2.WebView.IsAccessToDevToolsEnabled`                              Returns ``True`` if dev tools are available to the user.
:meth:`~wx.html2.WebView.IsBackendAvailable`                                     Allows to check if a specific backend is currently available.
:meth:`~wx.html2.WebView.IsBusy`                                                 Returns whether the web control is currently busy (e.g. loading a page).
:meth:`~wx.html2.WebView.IsContextMenuEnabled`                                   Returns ``True`` if a context menu will be shown on right click.
:meth:`~wx.html2.WebView.IsEditable`                                             Returns whether the web control is currently editable.
:meth:`~wx.html2.WebView.LoadURL`                                                Load a web page from a URL.
:meth:`~wx.html2.WebView.MSWSetEmulationLevel`                                   Sets emulation level.
:meth:`~wx.html2.WebView.MSWSetModernEmulationLevel`                             
:meth:`~wx.html2.WebView.New`                                                    Factory function to create a new :ref:`wx.html2.WebView`  with two-step creation, :meth:`wx.html2.WebView.Create`   should be called on the returned object.
:meth:`~wx.html2.WebView.Paste`                                                  Pastes the current data.
:meth:`~wx.html2.WebView.Print`                                                  Opens a print dialog so that the user may print the currently displayed page.
:meth:`~wx.html2.WebView.Redo`                                                   Redos the last action.
:meth:`~wx.html2.WebView.RegisterFactory`                                        Allows the registering of new backend for :ref:`wx.html2.WebView`.
:meth:`~wx.html2.WebView.RegisterHandler`                                        Registers a custom scheme handler.
:meth:`~wx.html2.WebView.Reload`                                                 Reload the currently displayed URL.
:meth:`~wx.html2.WebView.RemoveAllUserScripts`                                   Removes all user scripts from the web view.
:meth:`~wx.html2.WebView.RemoveScriptMessageHandler`                             Remove a script message handler with the given name that was previously added via :meth:`~WebView.AddScriptMessageHandler` .
:meth:`~wx.html2.WebView.RunScript`                                              Runs the given JavaScript code.
:meth:`~wx.html2.WebView.RunScriptAsync`                                         Runs the given JavaScript code asynchronously and returns the result via a  ``wxEVT_WEBVIEW_SCRIPT_RESULT`` .
:meth:`~wx.html2.WebView.SelectAll`                                              Selects the entire page.
:meth:`~wx.html2.WebView.SetEditable`                                            Set the editable property of the web control.
:meth:`~wx.html2.WebView.SetPage`                                                Set the displayed page source to the contents of the given string.
:meth:`~wx.html2.WebView.SetProxy`                                               Set the proxy to use for all requests.
:meth:`~wx.html2.WebView.SetUserAgent`                                           Specify a custom user agent string for the web view.
:meth:`~wx.html2.WebView.SetZoom`                                                Set the zoom level of the page.
:meth:`~wx.html2.WebView.SetZoomFactor`                                          Set the zoom factor of the page.
:meth:`~wx.html2.WebView.SetZoomType`                                            Set how to interpret the zoom factor.
:meth:`~wx.html2.WebView.ShowDevTools`                                           Show the dev tools window.
:meth:`~wx.html2.WebView.Stop`                                                   Stop the current page loading process, if any.
:meth:`~wx.html2.WebView.Undo`                                                   Undos the last action.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.html2.WebView.BackwardHistory`                                        See :meth:`~wx.html2.WebView.GetBackwardHistory`
:attr:`~wx.html2.WebView.CurrentTitle`                                           See :meth:`~wx.html2.WebView.GetCurrentTitle`
:attr:`~wx.html2.WebView.CurrentURL`                                             See :meth:`~wx.html2.WebView.GetCurrentURL`
:attr:`~wx.html2.WebView.ForwardHistory`                                         See :meth:`~wx.html2.WebView.GetForwardHistory`
:attr:`~wx.html2.WebView.NativeBackend`                                          See :meth:`~wx.html2.WebView.GetNativeBackend`
:attr:`~wx.html2.WebView.PageSource`                                             See :meth:`~wx.html2.WebView.GetPageSource`
:attr:`~wx.html2.WebView.PageText`                                               See :meth:`~wx.html2.WebView.GetPageText`
:attr:`~wx.html2.WebView.SelectedSource`                                         See :meth:`~wx.html2.WebView.GetSelectedSource`
:attr:`~wx.html2.WebView.SelectedText`                                           See :meth:`~wx.html2.WebView.GetSelectedText`
:attr:`~wx.html2.WebView.UserAgent`                                              See :meth:`~wx.html2.WebView.GetUserAgent` and :meth:`~wx.html2.WebView.SetUserAgent`
:attr:`~wx.html2.WebView.Zoom`                                                   See :meth:`~wx.html2.WebView.GetZoom` and :meth:`~wx.html2.WebView.SetZoom`
:attr:`~wx.html2.WebView.ZoomFactor`                                             See :meth:`~wx.html2.WebView.GetZoomFactor` and :meth:`~wx.html2.WebView.SetZoomFactor`
:attr:`~wx.html2.WebView.ZoomType`                                               See :meth:`~wx.html2.WebView.GetZoomType` and :meth:`~wx.html2.WebView.SetZoomType`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.html2.WebView(Control)

   This control may be used to render web (HTML / CSS / JavaScript)
   documents.



   .. method:: AddScriptMessageHandler(self, name)

      Add a script message handler with the given name. 
                 

      To use the script message handler from javascript use  ``window.<name>.postMessage(<messageBody>)``   where   ``<name>``   corresponds the value of the name parameter. The   ``<messageBody>``   will be available to the application via a   ``wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED``   event. 

      Sample C++ code receiving a script message: ::

          # Install message handler with the name wx_msg
          self.webView.AddScriptMessageHandler('wx_msg')
          # Bind an event handler to receive those messages
          self.webView.Bind(wx.EVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, self.handleMessage)



      Sample JavaScript sending a script message: ::

          # Send sample message body
          window.wx_msg.postMessage('This is a message body')






      :param `name`: Name of the message handler that can be used from JavaScript   
      :type `name`: string






      :rtype: `bool`




                  



      :returns: 

         ``True`` if the handler could be added, ``False`` if it could not be added.  







      .. versionadded:: 4.1/wxWidgets-3.1.5  
     







      .. note:: 

         The Edge backend only supports a single message handler and the Chromium and IE backends do not support script message handlers.  







      .. seealso:: :meth:`RemoveScriptMessageHandler`   








   .. method:: AddUserScript(self, javascript, injectionTime=WEBVIEW_INJECT_AT_DOCUMENT_START)

      Injects the specified script into the webpage's content. 
                 




      :param `javascript`: The JavaScript code to add.   
      :type `javascript`: string
      :param `injectionTime`: Specifies when the script will be executed.   
      :type `injectionTime`: wx.html2.WebViewUserScriptInjectionTime








      :rtype: `bool`




                  



      :returns: 

         ``True`` if the script was added successfully.  







      .. versionadded:: 4.1/wxWidgets-3.1.5  
     







      .. note:: 

         Please note that this is unsupported by the IE backend and the Edge backend does only support ``wx.html2.WEBVIEW_INJECT_AT_DOCUMENT_START``.  







      .. seealso:: :meth:`RemoveAllUserScripts`   








   .. method:: AreBrowserAcceleratorKeysEnabled(self)

      Returns ``True`` if browser accelerator keys are enabled. 
                 


                

      :rtype: `bool`







      .. versionadded:: 4.3/wxWidgets-3.3.0  
     








   .. method:: CanCopy(self)

      Returns ``True`` if the current selection can be copied. 
                 

      :rtype: `bool`








   .. method:: CanCut(self)

      Returns ``True`` if the current selection can be cut. 
                 

      :rtype: `bool`








   .. method:: CanGoBack(self)

      Returns ``True`` if it is possible to navigate backward in the history of visited pages. 
                 

      :rtype: `bool`








   .. method:: CanGoForward(self)

      Returns ``True`` if it is possible to navigate forward in the history of visited pages. 
                 

      :rtype: `bool`








   .. method:: CanPaste(self)

      Returns ``True`` if data can be pasted. 
                 

      :rtype: `bool`








   .. method:: CanRedo(self)

      Returns ``True`` if there is an action to redo. 
                 

      :rtype: `bool`








   .. method:: CanSetZoomType(self, type)

      Retrieve whether a zoom type is supported. 
                 




      :param `type`: The zoom type to test.   
      :type `type`: wx.html2.WebViewZoomType






      :rtype: `bool`




                  



      :returns: 

         ``True`` if this type of zoom is supported by this backend (and thus can be set through :meth:`SetZoomType` ).   








   .. method:: CanUndo(self)

      Returns ``True`` if there is an action to undo. 
                 

      :rtype: `bool`








   .. method:: ClearBrowsingData(self, types=WEBVIEW_BROWSING_DATA_ALL, since={})

      Clears the browsing data of the web view. 
                 

      This function clears the browsing data of the web view, such as cookies, cache, history, etc. The exact data that is cleared depends on the backend used. 

      This operation is asynchronous and may take some time to complete. When finished  ``wxEVT_WEBVIEW_BROWSING_DATA_CLEARED``   event is generated. 




      :param `types`: The types of browsing data to clear. By default, it clears all types of browsing data.   
      :type `types`: int
      :param `since`: The time since when the browsing data should be cleared. By default, it clears all browsing data.   
      :type `since`: wx.DateTime








      :rtype: `bool`




                  



      :returns: 

         ``False`` if backend doesn't support clearing browsing data or an error occurred. Otherwise, ``True`` is returned and the browsing data will be cleared asynchronously and the application will receive a  ``wxEVT_WEBVIEW_BROWSING_DATA_CLEARED``   event when it is done (or if doing it fails later).  







      .. versionadded:: 4.3/wxWidgets-3.3.0  
    







      .. note:: 

         This is only implemented in the Edge, WebKit2GTK+ and macOS backends.  







      .. seealso:: :ref:`wx.html2.WebViewBrowsingDataTypes`    








   .. method:: ClearHistory(self)

      Clear the history, this will also remove the visible page. 
                 


                

      :rtype: `None`     







      .. note:: 

         This is not implemented on the WebKit2GTK+ backend and macOS.   








   .. method:: ClearSelection(self)

      Clears the current selection. 
                 

      :rtype: `None`     








   .. method:: Copy(self)

      Copies the current selection. 
                 

      :rtype: `None`     








   .. method:: Create(self, parent, id=ID_ANY, url=WebViewDefaultURLStr, pos=DefaultPosition, size=DefaultSize, style=0, name=WebViewNameStr)

      Creation function for two-step creation. 
                 

      Please note that the object creation may be asynchronous when using some backends (e.g., `WebViewEdge`       or `WebViewChromium`     ) and the object is not really created until  ``wxEVT_WEBVIEW_CREATED``   event is received, so any non-trivial calls to its member functions should be delayed until then.  
                 


      :param `parent`: 
      :type `parent`: wx.Window
      :param `id`: 
      :type `id`: wx.WindowID
      :param `url`: 
      :type `url`: string
      :param `pos`: 
      :type `pos`: wx.Point
      :param `size`: 
      :type `size`: wx.Size
      :param `style`: 
      :type `style`: long
      :param `name`: 
      :type `name`: string




      :rtype: `bool`








   .. method:: Cut(self)

      Cuts the current selection. 
                 

      :rtype: `None`     








   .. method:: DeleteSelection(self)

      Deletes the current selection. 
                 

      Note that for  ``WEBVIEW_BACKEND_WEBKIT``   the selection must be editable, either through SetEditable or the correct HTML attribute.  
                 

      :rtype: `None`     








   .. method:: EnableAccessToDevTools(self, enable=True)

      Enable or disable access to dev tools for the user. 
                 

      Dev tools are disabled by default. 


                


      :param `enable`: 
      :type `enable`: bool




      :rtype: `None`     







      .. versionadded:: 4.1/wxWidgets-3.1.4  
    







      .. note:: 

         This is not implemented for the IE backend.  







      .. seealso:: :meth:`ShowDevTools`     








   .. method:: EnableBrowserAcceleratorKeys(self, enable=True)

      Enable or disable if browser accelerator keys are enabled. 
                 

      Browser accelerator keys are enabled by default. 

      The webview might implement various accelerator keys. This includes allowing accelerator key access to features such as printing and navigation. In many cases this might not be desired and the default keys can be disabled with this setting. 


                


      :param `enable`: 
      :type `enable`: bool




      :rtype: `None`     







      .. versionadded:: 4.3/wxWidgets-3.3.0  
     







      .. note:: 

         This is only implemented for the Edge backend.  








   .. method:: EnableContextMenu(self, enable=True)

      Enable or disable the right click context menu. 
                 

      By default the standard context menu is enabled, this method can be used to disable it or re-enable it later. 


                


      :param `enable`: 
      :type `enable`: bool




      :rtype: `None`     







      .. versionadded:: 2.9.5 
     








   .. method:: EnableHistory(self, enable=True)

      Enable or disable the history. 
                 

      This will also clear the history. 


                


      :param `enable`: 
      :type `enable`: bool




      :rtype: `None`     







      .. note:: 

         This is not implemented on the WebKit2GTK+ backend and macOS.   








   .. method:: Find(self, text, flags=WEBVIEW_FIND_DEFAULT)

      Finds a phrase on the current page and if found, the control will scroll the phrase into view and select it. 
                 




      :param `text`: The phrase to search for.   
      :type `text`: string
      :param `flags`: The flags for the search.   
      :type `flags`: wx.html2.WebViewFindFlags








      :rtype: `int`




                  



      :returns: 

         If search phrase was not found in combination with the flags then  ``NOT_FOUND``   is returned. If called for the first time with search phrase then the total number of results will be returned. Then for every time its called with the same search phrase it will return the number of the current match.    







      .. versionadded:: 2.9.5 
     







      .. note:: 

         This function will restart the search if the flags  ``WEBVIEW_FIND_ENTIRE_WORD``   or   ``WEBVIEW_FIND_MATCH_CASE``   are changed, since this will require a new search. To reset the search, for example resetting the highlights call the function with an empty search phrase.    








   .. method:: GetBackwardHistory(self)

      Returns a list of items in the back history. 
                 

      The first item in the vector is the first page that was loaded by the control. 
                 

      :rtype: `Any`     








   .. staticmethod:: GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)




      :param `variant`: 
      :type `variant`: wx.WindowVariant




      :rtype: `VisualAttributes`     








   .. method:: GetCurrentTitle(self)

      Get the title of the current web page, or its URL/path if title is not available. 
                 

      :rtype: `str`








   .. method:: GetCurrentURL(self)

      Get the URL of the currently displayed document. 
                 

      :rtype: `str`








   .. method:: GetForwardHistory(self)

      Returns a list of items in the forward history. 
                 

      The first item in the vector is the next item in the history with respect to the currently loaded page. 
                 

      :rtype: `Any`     








   .. method:: GetNativeBackend(self)

      Return the pointer to the native backend used by this control. 
                 

      This method can be used to retrieve the pointer to the native web engine used by this control. The return value needs to be down-casted to the appropriate type depending on the backend: 

      =========================== ================== ============================================================================================================== 
      Backend                     Platform           Type                                                                                                           
      =========================== ================== ============================================================================================================== 
      ``WEBVIEW_BACKEND_IE``      MSW                `IWebBrowser2 <https://learn.microsoft.com/windows/win32/api/exdisp/nn-exdisp-iwebbrowser2>`_                  
      ``WEBVIEW_BACKEND_EDGE``    MSW                `ICoreWebView2_2 <https://learn.microsoft.com/microsoft-edge/webview2/reference/win32/icorewebview2_2>`_       
      ``WEBVIEW_WEBKIT2``         ``GTK3``           `WebKitWebView <https://webkitgtk.org/reference/webkitgtk/stable/class.WebView.html>`_                         
      ``WEBVIEW_WEBKIT``          macOS              `WKWebView <https://developer.apple.com/documentation/webkit/wkwebview>`_                                      
      ``WEBVIEW_CHROMIUM``        MSW, macOS, GTK    `CefBrowser <https://cef-builds.spotifycdn.com/docs/116.0/classCefBrowser.html>`_                              
      =========================== ================== ============================================================================================================== 

      |



      For example, you could set the WebKit options using this method: ::

          # In Python the value returned will be a sip wrapper around a void* type,
          # and it can be converted to the address being pointed to with int().
          webview_ptr = self.webview.GetNativeBackend()

          # Assuming you are able to get a ctypes, cffi or similar access to the
          # webview library, you can use that pointer value to give it access to the
          # WebView backend to operate upon.
          theWebViewLib.doSomething(int(webview_ptr))




                

      :rtype: `Any`     







      .. versionadded:: 2.9.5 
     







      .. seealso:: :meth:`GetBackendVersionInfo`     








   .. method:: GetPageSource(self)

      Get the HTML source code of the currently displayed document. 
                 


                

      :rtype: `str`







      :returns: 

         The HTML source code, or an empty string if no page is currently shown.   








   .. method:: GetPageText(self)

      Get the text of the current page. 
                 

      :rtype: `str`








   .. method:: GetSelectedSource(self)

      Returns the currently selected source, if any. 
                 

      :rtype: `str`








   .. method:: GetSelectedText(self)

      Returns the currently selected text, if any. 
                 

      :rtype: `str`








   .. method:: GetUserAgent(self)

      Returns the current user agent string for the web view. 
                 


                

      :rtype: `str`







      .. versionadded:: 4.1/wxWidgets-3.1.5  
     








   .. method:: GetZoom(self)

      Get the zoom level of the page. 
                 

      See :meth:`GetZoomFactor`   to get more precise zoom scale value other than as provided by  ``WebViewZoom`` .  
                 

      :rtype: :ref:`wx.html2.WebViewZoom`







      :returns: 

         The current level of zoom.   








   .. method:: GetZoomFactor(self)

      Get the zoom factor of the page. 
                 


                

      :rtype: `float`







      :returns: 

         The current factor of zoom.   







      .. versionadded:: 4.1/wxWidgets-3.1.4  
     








   .. method:: GetZoomType(self)

      Get how the zoom factor is currently interpreted. 
                 


                

      :rtype: :ref:`wx.html2.WebViewZoomType`







      :returns: 

         How the zoom factor is currently interpreted by the backend.   








   .. method:: GoBack(self)

      Navigate back in the history of visited pages. 
                 

      Only valid if :meth:`CanGoBack`   returns ``True``. 
                 

      :rtype: `None`     








   .. method:: GoForward(self)

      Navigate forward in the history of visited pages. 
                 

      Only valid if :meth:`CanGoForward`   returns ``True``. 
                 

      :rtype: `None`     








   .. method:: HasSelection(self)

      Returns ``True`` if there is a current selection. 
                 

      :rtype: `bool`








   .. method:: IsAccessToDevToolsEnabled(self)

      Returns ``True`` if dev tools are available to the user. 
                 


                

      :rtype: `bool`







      .. versionadded:: 4.1/wxWidgets-3.1.4  
     








   .. staticmethod:: IsBackendAvailable(backend)

      Allows to check if a specific backend is currently available. 
                 

      For example, to check for Edge backend availability: ::

          if wx.html2.WebView.IsBackendAvailable(wx.html2.WebViewBackendEdge):
              # Do whatever you need to do when the Edge backend is available




                


      :param `backend`: 
      :type `backend`: string




      :rtype: `bool`







      .. versionadded:: 4.1/wxWidgets-3.1.4  
     








   .. method:: IsBusy(self)

      Returns whether the web control is currently busy (e.g. loading a page). 
                 

      :rtype: `bool`








   .. method:: IsContextMenuEnabled(self)

      Returns ``True`` if a context menu will be shown on right click. 
                 


                

      :rtype: `bool`







      .. versionadded:: 2.9.5 
     








   .. method:: IsEditable(self)

      Returns whether the web control is currently editable. 
                 

      :rtype: `bool`








   .. method:: LoadURL(self, url)

      Load a web page from a URL. 
                 




      :param `url`: The URL of the page to be loaded.   
      :type `url`: string






      :rtype: `None`     




                  



      .. note:: 

         Web engines generally report errors asynchronously, so if you wish to know whether loading the URL was successful, register to receive navigation error events.   








   .. staticmethod:: MSWSetEmulationLevel(level=WEBVIEWIE_EMU_IE11)

      Sets emulation level. 
                 

      This function is useful to change the emulation level of the system browser control used for :ref:`wx.html2.WebView`  implementation under MSW, rather than using the currently default, IE7-compatible, level. 

      Please notice that this function works by modifying the per-user part of MSW registry, which has several implications: first, it is sufficient to call it only once (per user) as the changes done by it are persistent and, second, if you do not want them to be persistent, you need to call it with  ``WEBVIEWIE_EMU_DEFAULT``   argument explicitly. 

      In particular, this function should be called to allow :meth:`RunScript`   to work for JavaScript code returning arbitrary objects, which is not supported at the default emulation level. 

      If set to a level higher than installed version, the highest available level will be used instead.  ``WEBVIEWIE_EMU_IE11``   is recommended for best performance and experience. 

      This function is MSW-specific and doesn't exist under other platforms. 

      See `https://msdn.microsoft.com/en-us/library/ee330730#browser_emulation <https://msdn.microsoft.com/en-us/library/ee330730#browser_emulation>`_  for more information about browser control emulation levels. 




      :param `level`: the target emulation level   
      :type `level`: wx.html2.WebViewIE_EmulationLevel






      :rtype: `bool`




                  



      :returns: 

         ``True`` on success, ``False`` on failure (a warning message is also logged in the latter case).  







      .. versionadded:: 4.1/wxWidgets-3.1.3  
     








   .. staticmethod:: MSWSetModernEmulationLevel(modernLevel=True)





      Please explicitly specify emulation level with :meth:`MSWSetEmulationLevel` . 




      :param `modernLevel`: ``True`` to set level to ``IE8``, synonym for  ``WEBVIEWIE_EMU_IE8`` . ``False`` to reset the emulation level to its default, synonym for   ``WEBVIEWIE_EMU_DEFAULT`` .    
      :type `modernLevel`: bool






      :rtype: `bool`




                  



      :returns: 

         ``True`` on success, ``False`` on failure (a warning message is also logged in the latter case).  







      .. versionadded:: 4.1/wxWidgets-3.1.1  
     







      .. wxdeprecated:: 
         This function is kept mostly for backwards compatibility.   








   .. staticmethod:: New(*args, **kw)



      |overload| **Overloaded Implementations:**

      :html:`<hr class="overloadsep" /><br />`

      
      **New** `(backend=WebViewBackendDefault)`
      
      Factory function to create a new :ref:`wx.html2.WebView`  with two-step creation, :meth:`wx.html2.WebView.Create`   should be called on the returned object. 
                       
      
      
      
      
      :param `backend`: The backend to use.   
      :type `backend`: string
      
      
      
      
      
      
      :rtype: :ref:`wx.html2.WebView`
      
      
      
      
                        
      
      
      
      :returns: 
      
         The created :ref:`wx.html2.WebView`.   
      
      
      
      
      
      
      
      .. versionadded:: 2.9.5 
           
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **New** `(config)`
      
      Factory function to create a new :ref:`wx.html2.WebView`  with two-step creation, :meth:`wx.html2.WebView.Create`   should be called on the returned object. 
                       
      
      
      
      
      :param `config`: a configuration object create with :meth:`NewConfiguration` .   
      :type `config`: wx.html2.WebViewConfiguration
      
      
      
      
      
      
      :rtype: :ref:`wx.html2.WebView`
      
      
      
      
                        
      
      
      
      :returns: 
      
         The created :ref:`wx.html2.WebView`    
      
      
      
      
      
      
      
      .. versionadded:: 4.3/wxWidgets-3.3.0  
           
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **New** `(parent, id=ID_ANY, url=WebViewDefaultURLStr, pos=DefaultPosition, size=DefaultSize, backend=WebViewBackendDefault, style=0, name=WebViewNameStr)`
      
      Factory function to create a new :ref:`wx.html2.WebView`  using a :ref:`wx.html2.WebViewFactory`. 
                       
      
      Note that the returned object may not be immediately usable yet, see :meth:`Create`   and wxEVT_WEBVIEW_CREATED. 
      
      
      
      
      :param `parent`: Parent window for the control   
      :type `parent`: wx.Window
      :param `id`: ``ID`` of this control   
      :type `id`: wx.WindowID
      :param `url`: Initial URL to load   
      :type `url`: string
      :param `pos`: Position of the control   
      :type `pos`: wx.Point
      :param `size`: Size of the control   
      :type `size`: wx.Size
      :param `backend`: The backend web engine to use.  ``WebViewBackendDefault``   and other backend names constants in format   ``WebViewBackend<Name>``   (e.g.,   ``WebViewBackendWebKit`` ) are predefined where appropriate. See  :ref:`Backend descriptions <wx.html2.WebView>`.   
      :type `backend`: string
      :param `style`: Window style. For generic window styles, please see :ref:`wx.Window`.   
      :type `style`: long
      :param `name`: Window name.   
      :type `name`: string
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      :rtype: :ref:`wx.html2.WebView`
      
      
      
      
                        
      
      
      
      :returns: 
      
         The created :ref:`wx.html2.WebView`, or nullptr if the requested backend is not available   
      
      
      
      
      
      
      
      .. versionadded:: 2.9.5 
           
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: Paste(self)

      Pastes the current data. 
                 

      :rtype: `None`     








   .. method:: Print(self)

      Opens a print dialog so that the user may print the currently displayed page. 
                 

      :rtype: `None`     








   .. method:: Redo(self)

      Redos the last action. 
                 

      :rtype: `None`     








   .. staticmethod:: RegisterFactory(backend, factory)

      Allows the registering of new backend for :ref:`wx.html2.WebView`. 
                 

      `backend`  can be used as an argument to :meth:`New` . 


      :param `backend`: The name for the new backend to be registered under   
      :type `backend`: string
      :param `factory`: A shared pointer to the factory which creates the appropriate backend.   
      :type `factory`: wx.html2.WebViewFactory








      :rtype: `None`     




                  



      .. versionadded:: 2.9.5 
     








   .. method:: RegisterHandler(self, handler)

      Registers a custom scheme handler. 
                 




      :param `handler`: A shared pointer to a WebHandler.   
      :type `handler`: wx.html2.WebViewHandler






      :rtype: `None`     




                  



      .. note:: 

         On macOS in order to use handlers two-step creation has to be used and :meth:`RegisterHandler`   has to be called before :meth:`Create` . With the other backends it has to be called after :meth:`Create` .  







      .. note:: 

         The Edge backend does not support custom schemes, but the handler is available as a virtual host under  `https://scheme.wxsite <https://scheme.wxsite>`_. To customize this virtual host call  :meth:`wx.html2.WebViewHandler.SetVirtualHost`   before registering the handler.   








   .. method:: Reload(self, flags=WEBVIEW_RELOAD_DEFAULT)

      Reload the currently displayed URL. 
                 




      :param `flags`: A bit array that may optionally contain reload options.   
      :type `flags`: wx.html2.WebViewReloadFlags






      :rtype: `None`     




                  



      .. note:: 

         The flags are ignored by the Edge backend.   








   .. method:: RemoveAllUserScripts(self)

      Removes all user scripts from the web view. 
                 


                

      :rtype: `None`     







      .. versionadded:: 4.1/wxWidgets-3.1.5  
     







      .. seealso:: :meth:`AddUserScript`   








   .. method:: RemoveScriptMessageHandler(self, name)

      Remove a script message handler with the given name that was previously added via :meth:`AddScriptMessageHandler` . 
                 


                


      :param `name`: 
      :type `name`: string




      :rtype: `bool`







      :returns: 

         ``True`` if the handler could be removed, ``False`` if it could not be removed.  







      .. versionadded:: 4.1/wxWidgets-3.1.5  
     







      .. seealso:: :meth:`AddScriptMessageHandler`   








   .. method:: RunScript(self, javascript)

      Runs the given JavaScript code. 
                 


      JavaScript code is executed inside the browser control and has full access to ``DOM`` and other browser-provided functionality. For example, this code  ::

          webview.RunScript("document.write('Hello from wx.Widgets!')")

      will replace the current page contents with the provided string. 

      If `output`  is non-null, it is filled with the result of executing this code on success, e.g. a JavaScript value such as a string, a number (integer or floating point), a boolean or ``JSON`` representation for non-primitive types such as arrays and objects. For example: ::

          success, result = webview.RunScript(
              "document.getElementById('some_id').innderHTML")

          if success:
              ... result contains the contents of the given element ...
    
          else:
              ... the element with self ID probably doesn't exist ...



      This function has a few platform-specific limitations: 



      - When using WebKit v1 in wxGTK2, retrieving the result of JavaScript execution is unsupported and this function will always return ``False`` if `output`  is non-null to indicate this. This functionality is fully supported when using WebKit v2 or later in ``GTK3``. 
      - When using WebKit under macOS, code execution is limited to at most 10MiB of memory and 10 seconds of execution time. 
      - When using Chromium backend, retrieving the result of JavaScript execution is unsupported and this function will always return ``False`` if `output`  is non-null to indicate this. 
      - When using IE backend under MSW, scripts can only be executed when the current page is fully loaded (i.e.  ``wxEVT_WEBVIEW_LOADED``   event was received). A script tag inside the page HTML is required in order to run JavaScript. 




      Also notice that with the IE backend converting JavaScript objects to ``JSON`` is not supported in the default emulation mode, it implements its own object-to-JSON conversion as a fallback for this case, however it is not as full-featured, well-tested or performing as the implementation of this functionality in the browser control itself, so it is recommended to use MSWSetEmulationLevel() to change emulation level to a more modern one in which ``JSON`` conversion is done by the control itself. 




      :param `javascript`: JavaScript code to execute.   
      :type `javascript`: string








      :rtype: :ref:`Tuple[bool, str]`




                  



      :returns: 

         ``True`` if there is a result, ``False`` if there is an error.  







      .. note:: 

         Because of various potential issues it's recommended to use :meth:`RunScriptAsync`   instead of this method. This is especially ``True`` if you plan to run code from a webview event and will also prevent unintended side effects on the UI outside of the webview.  







      .. seealso:: :meth:`RunScriptAsync`     








   .. method:: RunScriptAsync(self, javascript, clientData=nullptr)

      Runs the given JavaScript code asynchronously and returns the result via a  ``wxEVT_WEBVIEW_SCRIPT_RESULT`` .  
                 

      The script result value can be retrieved via :meth:`wx.html2.WebViewEvent.GetString` . If the execution fails :meth:`wx.html2.WebViewEvent.IsError`   will return ``True``. In this case additional script execution error information maybe available via :meth:`wx.html2.WebViewEvent.GetString` . 




      :param `javascript`: JavaScript code to execute.   
      :type `javascript`: string
      :param `clientData`: Arbirary pointer to data that can be retrieved from the result event.  








      :rtype: `None`     




                  



      .. versionadded:: 4.1/wxWidgets-3.1.6  
     







      .. note:: 

         The IE backend does not support async script execution.  







      .. seealso:: :meth:`RunScript`     








   .. method:: SelectAll(self)

      Selects the entire page. 
                 

      :rtype: `None`     








   .. method:: SetEditable(self, enable=True)

      Set the editable property of the web control. 
                 

      Enabling allows the user to edit the page even if the  ``contenteditable``   attribute is not set. The exact capabilities vary with the backend being used. 


                


      :param `enable`: 
      :type `enable`: bool




      :rtype: `None`     







      .. note:: 

         This is not implemented for macOS and the Edge backend.   








   .. method:: SetPage(self, *args, **kw)



      |overload| **Overloaded Implementations:**

      :html:`<hr class="overloadsep" /><br />`

      
      **SetPage** `(self, html, baseUrl)`
      
      Set the displayed page source to the contents of the given string. 
                       
      
      
      
      
      :param `html`: The string that contains the HTML data to display.   
      :type `html`: string
      :param `baseUrl`: URL assigned to the HTML data, to be used to resolve relative paths, for instance.   
      :type `baseUrl`: string
      
      
      
      
      
      
      
      
      :rtype: `None`     
      
      
      
      
                        
      
      
      
      .. note:: 
      
         When using  ``WEBVIEW_BACKEND_IE``   you must wait for the current page to finish loading before calling  :meth:`SetPage` . The baseURL parameter is not used in this backend and the Edge backend.   
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SetPage** `(self, html, baseUrl)`
      
      Set the displayed page source to the contents of the given stream. 
                       
      
      
      
      
      :param `html`: The stream to read HTML data from.   
      :type `html`: wx.InputStream
      :param `baseUrl`: URL assigned to the HTML data, to be used to resolve relative paths, for instance.   
      :type `baseUrl`: string
      
      
      
      
      
      
      
      
      :rtype: `None`     
      
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: SetProxy(self, proxy)

      Set the proxy to use for all requests. 
                 

      The `proxy`  string must be a valid proxy specification, e.g.  `http://my.local.proxy.corp:8080 <http://my.local.proxy.corp:8080>`_     

      Currently this function is only implemented in WebKit2, Edge and Chromium backends and only WebKit2 backend allows to set the proxy after creating the webview, so it is recommended to call it before :meth:`Create` :  


                


      :param `proxy`: 
      :type `proxy`: string




      :rtype: `bool`







      :returns: 

         ``True`` if proxy was set successfully or ``False`` if it failed, e.g. because this is not supported by the currently used backend.   








   .. method:: SetUserAgent(self, userAgent)

      Specify a custom user agent string for the web view. 
                 

      Returns ``True`` the user agent could be set. 

      If your first request should already use the custom user agent please use two step creation and call :meth:`SetUserAgent`   before :meth:`Create` . 


                


      :param `userAgent`: 
      :type `userAgent`: string




      :rtype: `bool`







      .. versionadded:: 4.1/wxWidgets-3.1.5  
     







      .. note:: 

         This is not implemented for IE.  








   .. method:: SetZoom(self, zoom)

      Set the zoom level of the page. 
                 

      See :meth:`SetZoomFactor`   for more precise scaling other than the measured steps provided by  ``WebViewZoom`` .  


      :param `zoom`: How much to zoom (scale) the HTML document.   
      :type `zoom`: wx.html2.WebViewZoom






      :rtype: `None`     




                  





   .. method:: SetZoomFactor(self, zoom)

      Set the zoom factor of the page. 
                 




      :param `zoom`: How much to zoom (scale) the HTML document in arbitrary number.   
      :type `zoom`: float






      :rtype: `None`     




                  



      .. versionadded:: 4.1/wxWidgets-3.1.4  
     







      .. note:: 

         zoom scale in IE will be converted into  ``WebViewZoom``   levels for   ``WebViewZoomType``   of   ``WEBVIEW_ZOOM_TYPE_TEXT`` .    








   .. method:: SetZoomType(self, zoomType)

      Set how to interpret the zoom factor. 
                 




      :param `zoomType`: How the zoom factor should be interpreted by the backend.   
      :type `zoomType`: wx.html2.WebViewZoomType






      :rtype: `None`     




                  



      .. note:: 

         invoke :meth:`CanSetZoomType`   first, some backends may not support all zoom types.   








   .. method:: ShowDevTools(self)

      Show the dev tools window. 
                 

      Immediately open the dev tools window. Does nothing if this window was already open. 

      Unlike :meth:`EnableAccessToDevTools` , which allows the user to open the dev tools window from the context menu, this function opens the same window programmatically. 

      Please note that while :meth:`ShowDevTools`   can be used whether access to the dev tools from the context menu was enabled or not, in WebKit2GTK+ backend calling it also enables interactive access to the dev tools from the context menu as a side effect. 


                

      :rtype: `bool`







      :returns: 

         ``True`` if the dev tools window is shown (even if it had been already shown before this function was called), ``False`` if it could not be shown for some reason, most likely because the backend does not provide this functionality.  







      .. versionadded:: 4.3/wxWidgets-3.3.0  
     







      .. note:: 

         This function is not implemented in the IE and WebKit (GTK/macOS) backends (but is implemented for WebKit2 GTK backend).  








   .. method:: Stop(self)

      Stop the current page loading process, if any. 
                 

      May trigger an error event of type  ``WEBVIEW_NAV_ERR_USER_CANCELLED`` . ``TODO``: make   ``WEBVIEW_NAV_ERR_USER_CANCELLED``   errors uniform across ports.  
                 

      :rtype: `None`     








   .. method:: Undo(self)

      Undos the last action. 
                 

      :rtype: `None`     








   .. attribute:: BackwardHistory

      See :meth:`~wx.html2.WebView.GetBackwardHistory`


   .. attribute:: CurrentTitle

      See :meth:`~wx.html2.WebView.GetCurrentTitle`


   .. attribute:: CurrentURL

      See :meth:`~wx.html2.WebView.GetCurrentURL`


   .. attribute:: ForwardHistory

      See :meth:`~wx.html2.WebView.GetForwardHistory`


   .. attribute:: NativeBackend

      See :meth:`~wx.html2.WebView.GetNativeBackend`


   .. attribute:: PageSource

      See :meth:`~wx.html2.WebView.GetPageSource`


   .. attribute:: PageText

      See :meth:`~wx.html2.WebView.GetPageText`


   .. attribute:: SelectedSource

      See :meth:`~wx.html2.WebView.GetSelectedSource`


   .. attribute:: SelectedText

      See :meth:`~wx.html2.WebView.GetSelectedText`


   .. attribute:: UserAgent

      See :meth:`~wx.html2.WebView.GetUserAgent` and :meth:`~wx.html2.WebView.SetUserAgent`


   .. attribute:: Zoom

      See :meth:`~wx.html2.WebView.GetZoom` and :meth:`~wx.html2.WebView.SetZoom`


   .. attribute:: ZoomFactor

      See :meth:`~wx.html2.WebView.GetZoomFactor` and :meth:`~wx.html2.WebView.SetZoomFactor`


   .. attribute:: ZoomType

      See :meth:`~wx.html2.WebView.GetZoomType` and :meth:`~wx.html2.WebView.SetZoomType`

