Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorporating CEFPython into Kivy App on Mac -- keyboard input doesn't work

I'm attempting to run the simple Kivy application located here on OSX.

At first, CEF failed during initialization. The output was:

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

I found a discussion here that suggested manually setting the local_pak flag to avoid this error. I made the following changes to the example code starting on line 150:

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

#init CEF
cefpython.Initialize(settings, g_switches)

This solved my initialization issue! The CEF Browser appears, but will not respond to any input from my keyboard. I am also unable to scroll using my trackpad, although I am able to use it to click links.

I gave the whole background on this issue in case I took the wrong route by changing the locale_pak flag.

I'm using:

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

I should also mention that I am able to run the wxpython.py example that is packaged with cefpython3 without issue.

Any help would be greatly appreciated!

like image 463
dslosky Avatar asked Nov 09 '22 09:11

dslosky


1 Answers

The issue is that in the kivy_.py example key codes were translated specifically for Linux only, see the translate_to_cef_keycode() function:

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

Support for Windows/OSX key codes needs yet to be added.

like image 110
Czarek Tomczak Avatar answered Nov 14 '22 23:11

Czarek Tomczak