We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 56f7419 commit ccc03c8Copy full SHA for ccc03c8
examples/snippets/onbeforeclose.py
@@ -0,0 +1,24 @@
1
+# Implement LifespanHandler.OnBeforeClose to execute custom
2
+# code before browser window closes.
3
+
4
+from cefpython3 import cefpython as cef
5
6
7
+def main():
8
+ cef.Initialize()
9
+ browser = cef.CreateBrowserSync(url="https://www.google.com/",
10
+ window_title="OnBeforeClose")
11
+ browser.SetClientHandler(LifespanHandler())
12
+ cef.MessageLoop()
13
+ del browser
14
+ cef.Shutdown()
15
16
17
+class LifespanHandler(object):
18
+ def OnBeforeClose(self, browser):
19
+ print("Browser ID: {}".format(browser.GetIdentifier()))
20
+ print("Browser will close and app will exit")
21
22
23
+if __name__ == '__main__':
24
+ main()
0 commit comments