forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonbeforeclose.py
More file actions
26 lines (19 loc) · 644 Bytes
/
onbeforeclose.py
File metadata and controls
26 lines (19 loc) · 644 Bytes
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
"""
Implement LifespanHandler.OnBeforeClose to execute custom
code before browser window closes.
"""
from cefpython3 import cefpython as cef
def main():
cef.Initialize()
browser = cef.CreateBrowserSync(url="https://www.google.com/",
window_title="OnBeforeClose")
browser.SetClientHandler(LifespanHandler())
cef.MessageLoop()
del browser
cef.Shutdown()
class LifespanHandler(object):
def OnBeforeClose(self, browser):
print("Browser ID: {}".format(browser.GetIdentifier()))
print("Browser will close and app will exit")
if __name__ == '__main__':
main()