MCPcopy Create free account
hub / github.com/cztomczak/cefpython / LoadHandler

Class LoadHandler

examples/screenshot.py:186–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184
185
186class LoadHandler(object):
187 def OnLoadingStateChange(self, browser, is_loading, **_):
188 """Called when the loading state has changed."""
189 if not is_loading:
190 # Loading is complete
191 sys.stdout.write(os.linesep)
192 print("[screenshot.py] Web page loading is complete")
193 print("[screenshot.py] Will save screenshot in 2 seconds")
194 # Give up to 2 seconds for the OnPaint call. Most of the time
195 # it is already called, but sometimes it may be called later.
196 cef.PostDelayedTask(cef.TID_UI, 2000, save_screenshot, browser)
197
198 def OnLoadError(self, browser, frame, error_code, failed_url, **_):
199 """Called when the resource load for a navigation fails
200 or is canceled."""
201 if not frame.IsMain():
202 # We are interested only in loading main url.
203 # Ignore any errors during loading of other frames.
204 return
205 print("[screenshot.py] ERROR: Failed to load url: {url}"
206 .format(url=failed_url))
207 print("[screenshot.py] Error code: {code}"
208 .format(code=error_code))
209 # See comments in exit_app() why PostTask must be used
210 cef.PostTask(cef.TID_UI, exit_app, browser)
211
212
213class RenderHandler(object):

Callers 1

create_browserFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected