Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cefpython123 #669

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.idea/
build/
dist/
venv/
*.log
__pycache__/
*.pyc
Expand All @@ -16,3 +17,5 @@ unittests/GPUCache/
unittests/blob_storage/
unittests/webrtc_event_logs/
.DS_Store
MediaDeviceSalts
MediaDeviceSalts-journal
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ support old operating systems then choose the v31 release.

OS | Py2 | Py3 | 32bit | 64bit | Requirements
--- | --- | --- | --- | --- | ---
Windows | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | Yes | Yes | Windows 7+
Linux | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | Yes | Yes | Debian 8+, Ubuntu 14.04+,<br> Fedora 24+, openSUSE 13.3+
Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | No | Yes | MacOS 10.9+
Windows | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 / 3.9 / 3.10 / 3.11 | Yes | Yes | Windows 7+
Linux | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 3.8 / 3.9 / 3.10 / 3.11 | Yes | Yes | Debian 8+, Ubuntu 14.04+,<br> Fedora 24+, openSUSE 13.3+
Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 / 3.9 / 3.10 / 3.11 | No | Yes | MacOS 10.9+

These platforms are not supported yet:
- ARM - see [Issue #267](../../issues/267)
Expand Down
20 changes: 10 additions & 10 deletions api/LifespanHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ the popup window and parent window will not be able to script each other.
There will be no "window.opener" property available in the popup window.

`WindowOpenDisposition` constants in the cefpython module:
* WOD_UNKNOWN,
* WOD_CURRENT_TAB,
* WOD_SINGLETON_TAB,
* WOD_NEW_FOREGROUND_TAB,
* WOD_NEW_BACKGROUND_TAB,
* WOD_NEW_POPUP,
* WOD_NEW_WINDOW,
* WOD_SAVE_TO_DISK,
* WOD_OFF_THE_RECORD,
* WOD_IGNORE_ACTION
* CEF_WOD_UNKNOWN,
* CEF_WOD_CURRENT_TAB,
* CEF_WOD_SINGLETON_TAB,
* CEF_WOD_NEW_FOREGROUND_TAB,
* CEF_WOD_NEW_BACKGROUND_TAB,
* CEF_WOD_NEW_POPUP,
* CEF_WOD_NEW_WINDOW,
* CEF_WOD_SAVE_TO_DISK,
* CEF_WOD_OFF_THE_RECORD,
* CEF_WOD_IGNORE_ACTION
4 changes: 3 additions & 1 deletion api/V8ContextHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

# V8ContextHandler (interface)

Implement this interface to handle javascript exceptions globally.
Implement this interface to handle render process callbacks.
Through inter-process messaging you are notified about these events
in the browser process.


Table of contents:
Expand Down
2 changes: 1 addition & 1 deletion docs/Build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ mkdir build/
cd build/
```

2) Download CEF binaries from [Spotify Automated Builds](http://opensource.spotify.com/cefbuilds/index.html).
2) Download CEF binaries from [Spotify Automated Builds](https://cef-builds.spotifycdn.com/index.html).
The version of the binaries must match exactly the CEF version
from the "cefpython/src/version/" directory (look for CEF_VERSION
constant in .h file).
Expand Down
3 changes: 2 additions & 1 deletion examples/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from cefpython3 import cefpython as cef
import platform
import sys
from pkg_resources import parse_version


def main():
Expand All @@ -24,7 +25,7 @@ def check_versions():
print("[hello_world.py] Python {ver} {arch}".format(
ver=platform.python_version(),
arch=platform.architecture()[0]))
assert cef.__version__ >= "57.0", "CEF Python v57.0+ required to run this"
assert parse_version(cef.__version__) >= parse_version("57.0"), "CEF Python v57.0+ required to run this"


if __name__ == '__main__':
Expand Down
9 changes: 7 additions & 2 deletions examples/pysdl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ def main():
dest='renderer',
choices=['software', 'hardware']
)
parser.add_argument(
'--debug',
help='debug app',
action='store_true'
)
args = parser.parse_args()
logLevel = logging.INFO
if args.verbose:
Expand All @@ -135,7 +140,7 @@ def main():
format='[%(filename)s %(levelname)s]: %(message)s',
level=logLevel
)
logging.info("Using PySDL2 %s" % sdl2.__version__)
logging.info("Using PySDL2 %s", sdl2.__version__)
version = sdl2.SDL_version()
sdl2.SDL_GetVersion(version)
logging.info(
Expand Down Expand Up @@ -224,7 +229,7 @@ def main():
browser.SetClientHandler(renderHandler)
# Must call WasResized at least once to let know CEF that
# viewport size is available and that OnPaint may be called.
browser.SendFocusEvent(True)
# browser.SendFocus(True)
browser.WasResized()

# Begin the main rendering loop
Expand Down
3 changes: 2 additions & 1 deletion examples/pywin32.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from cefpython3 import cefpython as cef

import distutils.sysconfig
from pkg_resources import parse_version
import math
import os
import platform
Expand Down Expand Up @@ -108,7 +109,7 @@ def check_versions():
pywin32_version = fp.read().strip()
print("[pywin32.py] pywin32 {ver}".format(ver=pywin32_version))

assert cef.__version__ >= "57.0", "CEF Python v57.0+ required to run this"
assert parse_version(cef.__version__) >= parse_version("57.0"), "CEF Python v57.0+ required to run this"


def create_browser(window_info, settings, url):
Expand Down
29 changes: 24 additions & 5 deletions examples/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
import os
import platform
import sys
from pkg_resources import parse_version

# GLOBALS
PYQT4 = False
PYQT5 = False
PYQT6 = False
PYSIDE = False
PYSIDE2 = False

Expand All @@ -39,6 +41,14 @@
from PyQt5.QtCore import *
# noinspection PyUnresolvedReferences
from PyQt5.QtWidgets import *
elif "pyqt6" in sys.argv:
PYQT6 = True
# noinspection PyUnresolvedReferences
from PyQt6.QtGui import *
# noinspection PyUnresolvedReferences
from PyQt6.QtCore import *
# noinspection PyUnresolvedReferences
from PyQt6.QtWidgets import *
elif "pyside" in sys.argv:
PYSIDE = True
# noinspection PyUnresolvedReferences
Expand All @@ -65,6 +75,7 @@
print("USAGE:")
print(" qt.py pyqt4")
print(" qt.py pyqt5")
print(" qt.py pyqt6")
print(" qt.py pyside")
print(" qt.py pyside2")
sys.exit(1)
Expand Down Expand Up @@ -104,7 +115,10 @@ def main():
main_window.show()
main_window.activateWindow()
main_window.raise_()
app.exec_()
if PYQT6:
app.exec()
else:
app.exec_()
if not cef.GetAppSetting("external_message_pump"):
app.stopTimer()
del main_window # Just to be safe, similarly to "del app"
Expand All @@ -116,7 +130,7 @@ def check_versions():
print("[qt.py] CEF Python {ver}".format(ver=cef.__version__))
print("[qt.py] Python {ver} {arch}".format(
ver=platform.python_version(), arch=platform.architecture()[0]))
if PYQT4 or PYQT5:
if PYQT4 or PYQT5 or PYQT6:
print("[qt.py] PyQt {v1} (qt {v2})".format(
v1=PYQT_VERSION_STR, v2=qVersion()))
elif PYSIDE:
Expand All @@ -126,7 +140,7 @@ def check_versions():
print("[qt.py] PySide2 {v1} (qt {v2})".format(
v1=PySide2.__version__, v2=QtCore.__version__))
# CEF Python version requirement
assert cef.__version__ >= "55.4", "CEF Python v55.4+ required to run this"
assert parse_version(cef.__version__) >= parse_version("55.4"), "CEF Python v55.4+ required to run this"


class MainWindow(QMainWindow):
Expand All @@ -142,11 +156,16 @@ def __init__(self):
self.setWindowTitle("PyQt4 example")
elif PYQT5:
self.setWindowTitle("PyQt5 example")
elif PYQT6:
self.setWindowTitle("PyQt6 example")
elif PYSIDE:
self.setWindowTitle("PySide example")
elif PYSIDE2:
self.setWindowTitle("PySide2 example")
self.setFocusPolicy(Qt.StrongFocus)
if PYQT6:
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
else:
self.setFocusPolicy(Qt.StrongFocus)
self.setupLayout()

def setupLayout(self):
Expand All @@ -167,7 +186,7 @@ def setupLayout(self):
frame.setLayout(layout)
self.setCentralWidget(frame)

if (PYSIDE2 or PYQT5) and WINDOWS:
if (PYSIDE2 or PYQT5 or PYQT6) and WINDOWS:
# On Windows with PyQt5 main window must be shown first
# before CEF browser is embedded, otherwise window is
# not resized and application hangs during resize.
Expand Down
8 changes: 5 additions & 3 deletions examples/screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@
"""

from cefpython3 import cefpython as cef
from pkg_resources import parse_version
import os
import platform
import subprocess
import sys

try:
from PIL import Image, PILLOW_VERSION
from PIL import Image, __version__ as PILLOW_VERSION
except ImportError:
print("[screenshot.py] Error: PIL module not available. To install"
" type: pip install Pillow")
Expand Down Expand Up @@ -99,7 +100,7 @@ def check_versions():
ver=platform.python_version(),
arch=platform.architecture()[0]))
print("[screenshot.py] Pillow {ver}".format(ver=PILLOW_VERSION))
assert cef.__version__ >= "57.0", "CEF Python v57.0+ required to run this"
assert parse_version(cef.__version__) >= parse_version("57.0"), "CEF Python v57.0+ required to run this"


def command_line_arguments():
Expand Down Expand Up @@ -139,9 +140,10 @@ def create_browser(settings):
browser = cef.CreateBrowserSync(window_info=window_info,
settings=settings,
url=URL)
print('created browser ', browser)
browser.SetClientHandler(LoadHandler())
browser.SetClientHandler(RenderHandler())
browser.SendFocusEvent(True)
# browser.SendFocus(True)
# You must call WasResized at least once to let know CEF that
# viewport size is available and that OnPaint may be called.
browser.WasResized()
Expand Down
3 changes: 2 additions & 1 deletion examples/tkinter_.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import os
import platform
import logging as _logging
from pkg_resources import parse_version

# Fix for PyCharm hints warnings
WindowUtils = cef.WindowUtils()
Expand Down Expand Up @@ -53,7 +54,7 @@ def main():
logger.info("Python {ver} {arch}".format(
ver=platform.python_version(), arch=platform.architecture()[0]))
logger.info("Tk {ver}".format(ver=tk.Tcl().eval('info patchlevel')))
assert cef.__version__ >= "55.3", "CEF Python v55.3+ required to run this"
assert parse_version(cef.__version__) >= parse_version("55.3"), "CEF Python v55.3+ required to run this"
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error
root = tk.Tk()
app = MainFrame(root)
Expand Down
4 changes: 3 additions & 1 deletion examples/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import platform
import sys
import threading
from pkg_resources import parse_version

# HTML code. Browser will navigate to a Data uri created
# from this html code.
Expand Down Expand Up @@ -85,7 +86,7 @@ def check_versions():
print("[tutorial.py] Python {ver} {arch}".format(
ver=platform.python_version(),
arch=platform.architecture()[0]))
assert cef.__version__ >= "57.0", "CEF Python v57.0+ required to run this"
assert parse_version(cef.__version__) >= parse_version("57.0"), "CEF Python v57.0+ required to run this"


def html_to_data_uri(html, js_callback=None):
Expand Down Expand Up @@ -188,6 +189,7 @@ def __init__(self, browser):

def test_multiple_callbacks(self, js_callback):
"""Test both javascript and python callbacks."""
print('in test_multiple_callbacks')
js_print(self.browser, "Python", "test_multiple_callbacks",
"Called from Javascript. Will call Javascript callback now.")

Expand Down
3 changes: 2 additions & 1 deletion examples/wxpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import platform
import sys
import os
from pkg_resources import parse_version

# Platforms
WINDOWS = (platform.system() == "Windows")
Expand Down Expand Up @@ -65,7 +66,7 @@ def check_versions():
ver=platform.python_version(), arch=platform.architecture()[0]))
print("[wxpython.py] wxPython {ver}".format(ver=wx.version()))
# CEF Python version requirement
assert cef.__version__ >= "66.0", "CEF Python v66.0+ required to run this"
assert parse_version(cef.__version__) >= parse_version("66.0"), "CEF Python v66.0+ required to run this"


def scale_window_size_for_high_dpi(width, height):
Expand Down
Loading