5

我正在尝试在 OSX 上运行位于此处的简单 Kivy 应用程序。

起初,CEF 在初始化期间失败。输出是:

igskcicgltgm047:Kivy_Test dslosky$ kivy cefTest4.py 
[INFO   ] [Logger      ] Record log in /Applications/Kivy.app/Contents/Resources/.kivy/logs/kivy_15-07-09_18.txt
[INFO   ] [Kivy        ] v1.9.0
[INFO   ] [Python      ] v2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
[INFO   ] [Factory     ] 173 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_imageio, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO   ] [OSC         ] using <multiprocessing> for socket
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] OpenGL version <2.1 NVIDIA-10.2.1 310.41.15f01>
[INFO   ] [GL          ] OpenGL vendor <NVIDIA Corporation>
[INFO   ] [GL          ] OpenGL renderer <NVIDIA GeForce GT 750M OpenGL Engine>
[INFO   ] [GL          ] OpenGL parsed version: 2, 1
[INFO   ] [GL          ] Shading version <1.20>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <16>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Base        ] Start application main loop
[INFO   ] [GL          ] NPOT texture support is available
[CEF Python] Initialize() called
[CEF Python] CefExecuteProcess(): exitCode = -1
[CEF Python] CefInitialize()
2015-07-09 12:20:09.283 python[4355:122290] Internals of CFAllocator not known; out-of-memory failures via CFAllocator will not result in termination. http://crbug.com/45650
[CEF Python] App_OnBeforeCommandLineProcessing_BrowserProcess()
[CEF Python] Command line string for the browser process:  --browser-subprocess-path=/Applications/Kivy.app/Contents/Resources/venv/lib/python2.7/site-packages/cefpython3/subprocess --lang=en-US --log-file=debug.log --log-severity=info --enable-release-dcheck --resources-dir-path=/Applications/Kivy.app/Contents/Resources/venv/lib/python2.7/site-packages/cefpython3 --locales-dir-path=/Applications/Kivy.app/Contents/Resources/venv/lib/python2.7/site-packages/cefpython3/locales --remote-debugging-port=51420 --no-sandbox
[0709/122009:WARNING:resource_bundle.cc(269)] locale_file_path.empty()
[0709/122009:FATAL:main_delegate.cc(449)] Check failed: !loaded_locale.empty(). Locale could not be found for en-US
Trace/BPT trap: 5

我在这里找到了一个讨论,建议手动设置local_pak标志以避免此错误。从第 150 行开始,我对示例代码进行了以下更改:

# Command line switches set programmatically
g_switches = {
    "locale_pak": cefpython.GetModuleDirectory()
    +"/Resources/en.lproj/locale.pak",
    }

#init CEF
cefpython.Initialize(settings, g_switches)

这解决了我的初始化问题!CEF 浏览器出现,但不会响应我键盘的任何输入。我也无法使用触控板滚动,尽管我可以使用它来点击链接。

我给出了这个问题的全部背景,以防我通过更改locale_pak标志走错了路。

我在用着:

Kivy v1.9.0  
Python v2.7.6  
cefpython3 v31.2  

我还应该提到,我能够毫无问题地运行wxpython.py打包的示例。cefpython3

任何帮助将不胜感激!

4

1 回答 1

1

问题是在 kivy_.py 示例中,密钥代码仅针对 Linux 进行了翻译,请参见 translate_to_cef_keycode() 函数:

https://code.google.com/p/cefpython/source/browse/cefpython/cef3/linux/binaries_64bit/kivy_.py?r=5cf79c6eec11#355

还需要添加对 Windows/OSX 键码的支持。

于 2015-07-09T19:45:34.797 回答