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,
- Select the target in the Widget Tree =>
~/Frame/WebView
. - Press the [Events] button.
- Then, press [Add Module] and input
wx.html2
in the dialog box. - Type
obj
in Pycrust to access the target object.
For example,
>>> obj
<wx._html2.WebView object at 0x000002C36C0B18B0>
>>> obj.DoSomething()
Something happens.