FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cefpython/examples/snippets/onpagecomplete.py at cefpython66 · 2php/cefpython · GitHub
2php
cefpython
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cefpython
/
examples
/
snippets
/
onpagecomplete.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (27 loc) · 1.13 KB
Breadcrumbs
cefpython
/
examples
/
snippets
/
onpagecomplete.py
Copy path
File metadata and controls
35 lines (27 loc) · 1.13 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Execute custom Python code on a web page when page loading is complete.
Implements a custom "_OnPageComplete" event in the LoadHandler object.
"""
from
cefpython3
import
cefpython
as
cef
def
main
():
cef
.
Initialize
()
browser
=
cef
.
CreateBrowserSync
(
url
=
"https://www.google.com/"
,
window_title
=
"_OnPageComplete event"
)
browser
.
SetClientHandler
(
LoadHandler
())
cef
.
MessageLoop
()
del
browser
cef
.
Shutdown
()
class
LoadHandler
(
object
):
def
OnLoadingStateChange
(
self
,
browser
,
is_loading
,
**
_
):
"""For detecting if page loading has ended it is recommended
to use OnLoadingStateChange which is most reliable. The OnLoadEnd
callback also available in LoadHandler can sometimes fail in
some cases e.g. when image loading hangs."""
if
not
is_loading
:
self
.
_OnPageComplete
(
browser
)
def
_OnPageComplete
(
self
,
browser
):
print
(
"Page loading is complete!"
)
browser
.
ExecuteFunction
(
"alert"
,
"Message from Python: Page loading"
" is complete!"
)
if
__name__
==
'__main__'
:
main
()
Back
|
FazBrowse Home
|
New Git URL