Jun-03-2018, 12:57 AM
when a webpage loading, it generates event more than once. Google in the code below, has the event fired twice. some webpage has more than 10 times. it is because of multiple frames or something. I want to wait for page fully loaded before continuing rest process. Is there a way to do it? Thanks.
import wx import wx.html2 class MyBrowser(wx.Dialog): def __init__(self, *args, **kwds): wx.Dialog.__init__(self, *args, **kwds) sizer = wx.BoxSizer(wx.VERTICAL) self.browser = wx.html2.WebView.New(self) self.Bind(wx.html2.EVT_WEBVIEW_LOADED, self.On_Web_View_Loaded, self.browser) sizer.Add(self.browser, 1, wx.EXPAND, 10) self.SetSizer(sizer) self.SetSize((700, 700)) def On_Web_View_Loaded(self, event): print('Loading') if __name__ == '__main__': app = wx.App() dialog = MyBrowser(None, -1) dialog.browser.LoadURL("http://www.google.com") dialog.Show() app.MainLoop()