Wx.html2.webview debugging

Hi,

Have you tried InspectionTool? That’s easy and powerful! You only need to add a few lines in your code as follows.

import wx
import wx.html2

if __name__ == '__main__':
    app = wx.App()
    frm = wx.Frame(None)
    browser = wx.html2.WebView.New(frm)
    browser.LoadURL("https://www.google.com")
    if 1:
        from wx.lib.inspection import InspectionTool
        it = InspectionTool()
        it.Show()
    frm.Show()
    app.MainLoop()

To watch the WebViewEvent while navigating and inspect/debug the target in the InspectionTool,

  1. Select the target in the Widget Tree => ~/Frame/WebView.
  2. Press the [Events] button.
  3. Then, press [Add Module] and input wx.html2 in the dialog box.
  4. Type obj in Pycrust to access the target object.

For example,

>>> obj
<wx._html2.WebView object at 0x000002C36C0B18B0>
>>> obj.DoSomething()
Something happens.