37,744
社区成员




# -- coding=utf8 --
from cefpython3 import cefpython as cef
import platform
import sys
import json
def main():
check_versions()
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error
cef.Initialize()
br = cef.CreateBrowserSync(url="file:///F:\\workspace\\eclipse-workspace\\Demo01\\html\\demo.html", window_title="Hello World!")
js = cef.JavascriptBindings()
js.SetFunction("py_func", py_func)
js.SetProperty("other", {"a": 1})
br.SetJavascriptBindings(js)
#cef.CreateBrowser(url="http://www.baidu.com", window_title="Hello World!")
cef.MessageLoop()
cef.Shutdown()
def py_func():
print("i am in python")
def check_versions():
ver = cef.GetVersion()
print("[hello_world.py] CEF Python {ver}".format(ver=ver["version"]))
print("[hello_world.py] Chromium {ver}".format(ver=ver["chrome_version"]))
print("[hello_world.py] CEF {ver}".format(ver=ver["cef_version"]))
print("[hello_world.py] Python {ver} {arch}".format(
ver=platform.python_version(),
arch=platform.architecture()[0]))
assert cef.__version__ >= "57.0", "CEF Python v57.0+ required to run this"
if __name__ == '__main__':
main()