-
-
Notifications
You must be signed in to change notification settings - Fork 475
/
Copy pathhello_world.py
30 lines (22 loc) · 899 Bytes
/
hello_world.py
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
# Hello world example. Doesn't depend on any third party GUI framework.
# Tested with CEF Python v53+.
from cefpython3 import cefpython as cef
import sys
def main():
print("CEF Python {ver}".format(ver=cef.__version__))
print("Python {ver}".format(ver=sys.version[:6]))
assert cef.__version__ >= "53.1", "CEF Python v53.1+ required to run this"
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error
cef.Initialize()
browser = cef.CreateBrowserSync(url="https://www.google.com/")
browser.SetClientHandler(ClientHandler())
cef.MessageLoop()
cef.Shutdown()
class ClientHandler(object):
def OnBeforeClose(self, browser):
"""Called just before a browser is destroyed."""
if not browser.IsPopup():
# Exit app when main window is closed.
cef.QuitMessageLoop()
if __name__ == '__main__':
main()