Currently using Ubuntu 16.04.2 + XFCE (Not Xubuntu, though) with libgtk 2.24.30-1ubuntu1. Here's the diff for my gtk2.py file:
diff --git a/examples/gtk2.py b/examples/gtk2.py
index 99d7cc1..0afabf8 100644
--- a/examples/gtk2.py
+++ b/examples/gtk2.py
@@ -86,7 +86,7 @@ class Gtk2Example:
self.main_window.set_title('GTK 2 example (PyGTK)')
icon = os.path.join(os.path.dirname(__file__), "resources", "gtk.png")
if os.path.exists(icon):
- self.main_window.set_icon_from_file(icon)
+ pass #self.main_window.set_icon_from_file(icon)
self.main_window.realize()
self.vbox = gtk.VBox(False, 0)
@@ -110,8 +110,10 @@ class Gtk2Example:
size = self.main_window.get_size()
rect = [0, 0, size[0], size[1]]
windowInfo.SetAsChild(self.get_window_handle(), rect)
+ print "HERE"
self.browser = cef.CreateBrowserSync(windowInfo, settings={},
url="https://www.google.com/")
+ print "THERE"
self.browser.SetClientHandler(LoadHandler())
def get_window_handle(self):
laptus@newptus:~/src/cefpython/examples$ python gtk2.py --debug
[gtk2.py] CEF Python 56.1
[gtk2.py] Python 2.7.12 64bit
[gtk2.py] GTK 2.24.30
[gtk2.py] Message loop mode: TIMER
[CEF Python] Initialize() called
[CEF Python] CefExecuteProcess(): exitCode = -1
[CEF Python] CefInitialize()
[CEF Python] App_OnBeforeCommandLineProcessing_BrowserProcess()
[CEF Python] Command line string for the browser process: --browser-subprocess-path=/usr/local/lib/python2.7/dist-packages/cefpython3/subprocess --no-sandbox --lang=en-US --log-file=/usr/local/lib/python2.7/dist-packages/cefpython3/debug.log --log-severity=warning --resources-dir-path=/usr/local/lib/python2.7/dist-packages/cefpython3 --locales-dir-path=/usr/local/lib/python2.7/dist-packages/cefpython3/locales --remote-debugging-port=64107
[CEF Python] BrowserProcessHandler_OnBeforeChildProcessLaunch()
[CEF Python] WindowUtils::IsWindowHandle() not implemented (always True)
[CEF Python] CreateBrowserSync() called
[CEF Python] navigateUrl: https://www.google.com/
[CEF Python] CefBrowser::CreateBrowserSync()
[CEF Python] X error received: type 0, serial 101, error_code 3, request_code 1, minor_code 0
[CEF Python] X error received: type 0, serial 102, error_code 3, request_code 2, minor_code 0
[CEF Python] X error received: type 0, serial 103, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 104, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 106, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 107, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 146, error_code 3, request_code 1, minor_code 0
[CEF Python] X error received: type 0, serial 148, error_code 3, request_code 131, minor_code 46
[CEF Python] X error received: type 0, serial 149, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 150, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 151, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 152, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 153, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 155, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 274, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 276, error_code 3, request_code 129, minor_code 1
[CEF Python] X error received: type 0, serial 284, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 285, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 290, error_code 3, request_code 18, minor_code 0
[CEF Python] X error received: type 0, serial 291, error_code 3, request_code 8, minor_code 0
---------------------------------
And a log of a successful run:
laptus@newptus:~/src/cefpython/examples$ python gtk2.py --debug
[gtk2.py] CEF Python 56.1
[gtk2.py] Python 2.7.12 64bit
[gtk2.py] GTK 2.24.30
[gtk2.py] Message loop mode: TIMER
[CEF Python] Initialize() called
[CEF Python] CefExecuteProcess(): exitCode = -1
[CEF Python] CefInitialize()
[CEF Python] App_OnBeforeCommandLineProcessing_BrowserProcess()
[CEF Python] Command line string for the browser process: --browser-subprocess-path=/usr/local/lib/python2.7/dist-packages/cefpython3/subprocess --no-sandbox --lang=en-US --log-file=/usr/local/lib/python2.7/dist-packages/cefpython3/debug.log --log-severity=warning --resources-dir-path=/usr/local/lib/python2.7/dist-packages/cefpython3 --locales-dir-path=/usr/local/lib/python2.7/dist-packages/cefpython3/locales --remote-debugging-port=60650
[CEF Python] BrowserProcessHandler_OnBeforeChildProcessLaunch()
[CEF Python] WindowUtils::IsWindowHandle() not implemented (always True)
[CEF Python] CreateBrowserSync() called
[CEF Python] navigateUrl: https://www.google.com/
[CEF Python] CefBrowser::CreateBrowserSync()
[CEF Python] GetPyBrowser(): create new PyBrowser, browserId=1
[CEF Python] BrowserProcessHandler_OnBeforeChildProcessLaunch()
[CEF Python] CefBrowser::CreateBrowserSync() succeeded
[CEF Python] Command line string for the zygote process: /usr/local/lib/python2.7/dist-packages/cefpython3/subprocess --type=zygote --no-sandbox --lang=en-US --locales-dir-path=/usr/local/lib/python2.7/dist-packages/cefpython3/locales --log-file=/usr/local/lib/python2.7/dist-packages/cefpython3/debug.log --log-severity=warning --resources-dir-path=/usr/local/lib/python2.7/dist-packages/cefpython3
[gtk2.py] LoadHandler.OnLoadStart: keyboard focus fix (Issue #284)
[CEF Python] Renderer: OnContextCreated()
[CEF Python] Browser: OnProcessMessageReceived(): OnContextCreated
[CEF Python] V8ContextHandler_OnContextCreated()
[0416/140841.607403:WARNING:quota_manager.cc(1833)] Create directory failed for path
[0416/140841.608137:WARNING:quota_manager.cc(1833)] Create directory failed for path
No modifications (I can trigger this problem, for example, by removing the icon file).
> What does self.get_window_handle() return before calling CreateBrowserSync?
Something that looks like a reasonably valid handle (69206019, if that's important). If I run the example twice, one triggering the problem and the other without, the number is the same.
self.vbox.show()
self.main_window.show()
self.embed_browser()
> Try to show window before browser is embedded and see if it makes any difference:
That seems to work! Doing self.embed_browser() after show()ing the windows indeed fixes (or works around?) the problem. Any idea why? Thanks Czarek!