1

我已经使用 CEFPython 创建了一个包,它可以在 Windows 机器上完美运行。但是,当在 Mac 机器上使用时MessageLoop(),无论是否打开一个完全白色的窗口,脚本都会挂起。我正在使用 CEFpython3(版本 66.0)python 3.7 MacOS 10.15

这是我的脚本:(我开发了一个基于网络的可视化工具,需要“config”作为输入,“index_cefpython.html”是页面)

def view(config):
    settings = {
        "debug": True,
        "log_severity": cef.LOGSEVERITY_INFO,
        "log_file": "debug.log",
    }
    cef.Initialize(settings=settings)
    cwd = os.getcwd()

    browser_setting = { "file_access_from_file_urls_allowed":True,\
                    "universal_access_from_file_urls_allowed": True,\
                    "web_security_disabled":True}
    dir_path = os.path.dirname(__file__)
    index_filepath = os.path.join(dir_path, 'static/index_cefpython.html')
    browser = cef.CreateBrowserSync(url=index_filepath,
                                    window_title="ElectroLens", settings = browser_setting)
    os.chdir(cwd)
    browser.SetClientHandler(LoadHandler(config))
    bindings = cef.JavascriptBindings()
    browser.SetJavascriptBindings(bindings)
    cef.MessageLoop()
    del browser
    cef.Shutdown()
    return

class LoadHandler(object):

    def __init__(self, config):
        self.config = config
    def OnLoadEnd(self, browser, **_):
        browser.ExecuteFunction("defineData", self.config)


view(config)

这是整个输出:

 [0515/213941.116530:INFO:cef_log.cpp(8)] [Browser process] Initialize() called


[0515/213941.144667:INFO:cef_log.cpp(8)] [Browser process] CefInitialize()


[0515/213941.145197:INFO:cef_log.cpp(8)] [Browser process] App_OnBeforeCommandLineProcessing_BrowserProcess()


[0515/213941.145229:INFO:cefpython_app.cpp(105)] [Browser process] Command line string for the browser process:  --browser-subprocess-path=/Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/cefpython3/subprocess --framework-dir-path=/Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/cefpython3/Chromium Embedded Framework.framework --no-sandbox --lang=en-US --log-file=debug.log --log-severity=info --resources-dir-path=/Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/cefpython3/Chromium Embedded Framework.framework/Resources --remote-debugging-port=63329 --disable-gpu-shader-disk-cache


[0515/213941.149767:INFO:cefpython_app.cpp(199)] [Browser process] OnBeforeChildProcessLaunch() command line: /Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/cefpython3/subprocess --type=gpu-process --no-sandbox --framework-dir-path=/Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/cefpython3/Chromium Embedded Framework.framework --log-file=debug.log --log-severity=info --resources-dir-path=/Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/cefpython3/Chromium Embedded Framework.framework/Resources --lang=en-US --disable-gpu-shader-disk-cache



DevTools listening on ws://127.0.0.1:63329/devtools/browser/b7cb600e-cdc0-46ca-a019-71651fada2ed

[0515/213941.153593:INFO:cef_log.cpp(8)] [Browser process] CreateBrowserSync() called


[0515/213941.157857:INFO:cef_log.cpp(8)] [Browser process] navigateUrl: /Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/ElectroLens/static/index_cefpython.html


[0515/213941.157891:INFO:cef_log.cpp(8)] [Browser process] CefBrowser::CreateBrowserSync()


[0515/213941.158481:INFO:cef_log.cpp(8)] [Browser process] Switch already set, ignoring: disable-gpu-shader-disk-cache


[0515/213941.158528:INFO:cefpython_app.cpp(199)] [Browser process] OnBeforeChildProcessLaunch() command line: /Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/cefpython3/subprocess --type=gpu-process --no-sandbox --framework-dir-path=/Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/cefpython3/Chromium Embedded Framework.framework --log-file=debug.log --log-severity=info --resources-dir-path=/Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/cefpython3/Chromium Embedded Framework.framework/Resources --lang=en-US --disable-gpu-shader-disk-cache --gpu-preferences=KAAAAAAAAACAAIAAAQAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAAAADgBAAAmAAAAMAEAAAAAAAA4AQAAAAAAAEABAAAAAAAASAEAAAAAAABQAQAAAAAAAFgBAAAAAAAAYAEAAAAAAABoAQAAAAAAAHABAAAAAA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ABAAAAAAAAAABgAAABIAAAAQAAAAAAAAAAYAAAATAAAA --framework-dir-path=/Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/cefpython3/Chromium Embedded Framework.framework --log-file=debug.log --log-severity=info --resources-dir-path=/Applications/anaconda3/envs/electrolens/lib/python3.7/site-packages/cefpython3/Chromium Embedded Framework.framework/Resources --lang=en-US


[0515/213941.184387:INFO:cef_log.cpp(8)] [Browser process] GetPyBrowser(): create new PyBrowser, browserId=1


[0515/213941.184448:INFO:cef_log.cpp(8)] [Browser process] CefBrowser::CreateBrowserSync() succeeded


[0515/213941.184472:INFO:cef_log.cpp(8)] [Browser process] CefBrowser window handle = 140624771323600


[0515/213941.184981:INFO:cef_log.cpp(8)] [Browser process] SendProcessMessage(): message=DoJavascriptBindings, arguments size=1


[0515/213941.185021:INFO:cef_log.cpp(8)] [Browser process] MessageLoop()
4

0 回答 0