Skip to content

Commit

Permalink
Add onbeforeclose.py snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
cztomczak committed Aug 19, 2018
1 parent 56f7419 commit ccc03c8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions examples/snippets/onbeforeclose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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()

0 comments on commit ccc03c8

Please sign in to comment.