wxPython example is working, binaries updated. To make it · pythonthings/cefpython@36c0759 · GitHub
Skip to content

Commit 36c0759

Browse files
committed
wxPython example is working, binaries updated. To make it
work with wxPython on Linux it was required to make changes in CEF C++ sources, a patch is in the linux directory.
1 parent 78b5f8d commit 36c0759

4 files changed

Lines changed: 93 additions & 46 deletions

File tree

Lines changed: 54 additions & 0 deletions

cefpython/cef1/linux/binaries/pygtk_.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
1-
# An example of embedding CEF in PyGTK application.
1+
# An example of embedding CEF browser in PyGTK on Linux.
22

33
import platform
44
if platform.architecture()[0] != "32bit":
55
raise Exception("Only 32bit architecture is supported")
66

7-
import ctypes, os
8-
ctypes.CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'libcef.so'), ctypes.RTLD_GLOBAL)
9-
import cefpython_py27 as cefpython
10-
11-
import sys
12-
13-
"""
14-
try:
15-
# Import local PYD file (portable zip).
7+
import ctypes, os, sys
8+
libcef_so = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'libcef.so')
9+
if os.path.exists(libcef_so):
10+
# Import local module
11+
ctypes.CDLL(libcef_so, ctypes.RTLD_GLOBAL)
1612
if sys.hexversion >= 0x02070000 and sys.hexversion < 0x03000000:
1713
import cefpython_py27 as cefpython
18-
elif sys.hexversion >= 0x03000000 and sys.hexversion < 0x04000000:
19-
import cefpython_py32 as cefpython
2014
else:
2115
raise Exception("Unsupported python version: %s" % sys.version)
22-
except ImportError:
23-
# Import from package (installer).
16+
else:
17+
# Import from package
2418
from cefpython1 import cefpython
25-
"""
2619

2720
import pygtk
2821
pygtk.require('2.0')
2922
import gtk
3023
import gobject
31-
import ctypes
3224
import re
3325

3426
def GetApplicationPath(file=None):
@@ -101,9 +93,9 @@ def __init__(self):
10193

10294
# Must be show_all() for VBox otherwise browser doesn't
10395
# appear when you just call show().
104-
self.vbox.show_all()
96+
self.vbox.show()
10597

106-
self.mainWindow.show()
98+
self.mainWindow.show()
10799
gobject.timeout_add(10, self.OnTimer)
108100

109101
def CreateMenu(self):

cefpython/cef1/linux/binaries/wxpython.py

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
1-
# An example of embedding CEF in wxPython application.
1+
# An example of embedding CEF browser in wxPython on Linux.
22

33
import platform
44
if platform.architecture()[0] != "32bit":
55
raise Exception("Only 32bit architecture is supported")
66

7-
import ctypes, os
8-
ctypes.CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'libcef.so'), ctypes.RTLD_GLOBAL)
9-
import cefpython_py27 as cefpython
10-
11-
import sys
12-
"""
13-
try:
14-
# Import local PYD file (portable zip).
7+
import ctypes, os, sys
8+
libcef_so = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'libcef.so')
9+
if os.path.exists(libcef_so):
10+
# Import local module
11+
ctypes.CDLL(libcef_so, ctypes.RTLD_GLOBAL)
1512
if sys.hexversion >= 0x02070000 and sys.hexversion < 0x03000000:
1613
import cefpython_py27 as cefpython
17-
elif sys.hexversion >= 0x03000000 and sys.hexversion < 0x04000000:
18-
import cefpython_py32 as cefpython
1914
else:
2015
raise Exception("Unsupported python version: %s" % sys.version)
21-
except ImportError:
22-
# Import from package (installer).
16+
else:
17+
# Import from package
2318
from cefpython1 import cefpython
24-
"""
2519

2620
import wx
2721
import time
2822

2923
# Which method to use for message loop processing.
3024
# EVT_IDLE - wx application has priority (default)
3125
# EVT_TIMER - cef browser has priority
32-
# From the tests it seems that Flash content behaves
33-
# better when using a timer.
34-
35-
# IMPORTANT! On Linux CPU goes 100% when using EVT_IDLE, why?
26+
# It seems that Flash content behaves better when using a timer.
27+
# IMPORTANT! On Linux EVT_IDLE does not work, the events seems to
28+
# be propagated only when you move your mouse, which is not the
29+
# expected behavior, it is recommended to use EVT_TIMER on Linux,
30+
# so set this value to False.
3631
USE_EVT_IDLE = False
3732

3833
def GetApplicationPath(file=None):
@@ -73,35 +68,33 @@ class MainFrame(wx.Frame):
7368
browser = None
7469
initialized = False
7570
idleCount = 0
71+
box = None
7672

7773
def __init__(self):
7874
wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,
7975
title='wxPython example', size=(600,400))
8076
self.CreateMenu()
8177

8278
windowInfo = cefpython.WindowInfo()
83-
windowInfo.SetAsChild(self.GetWindowHandle())
79+
windowInfo.SetAsChild(self.GetGtkWidget())
8480
print("wxpython.py: creating browser in a moment")
8581
# Linux requires adding "file://" for local files,
8682
# otherwise /home/some will be replaced as http://home/some
8783
self.browser = cefpython.CreateBrowserSync(
8884
windowInfo,
8985
browserSettings={},
90-
navigateUrl="file://"+GetApplicationPath("cefsimple.html")))
91-
print("wxpython.py: browser created, handle = %s" % self.GetWindowHandle())
86+
navigateUrl="file://"+GetApplicationPath("cefsimple.html"))
87+
print("wxpython.py: browser created")
9288

93-
# Remains of windows code:
89+
# Remains of OS_WIN code:
9490
#self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
9591
#self.Bind(wx.EVT_SIZE, self.OnSize)
96-
92+
9793
self.Bind(wx.EVT_CLOSE, self.OnClose)
9894
if USE_EVT_IDLE:
9995
# Bind EVT_IDLE only for the main application frame.
10096
self.Bind(wx.EVT_IDLE, self.OnIdle)
10197

102-
def GetWindowHandle(self):
103-
return self.GetGtkWidget()
104-
10598
def CreateMenu(self):
10699
filemenu = wx.Menu()
107100
filemenu.Append(1, "Open")

cefpython/cef1/linux/setup/setup.py

Lines changed: 10 additions & 2 deletions

0 commit comments

Comments
 (0)