### Install and Run Hello World Example Source: https://github.com/cztomczak/cefpython/blob/master/examples/README-examples.md Instructions to install cefpython3, clone the repository, and run the basic 'hello_world.py' example. ```bash pip install cefpython3==66.0 git clone https://github.com/cztomczak/cefpython.git cd cefpython/examples/ python hello_world.py ``` -------------------------------- ### Run CEF Python Examples Source: https://github.com/cztomczak/cefpython/blob/master/tools/installer/cefpython3.README.txt Navigate to the examples directory and run the 'hello_world.py' script to start with the examples. ```bash cd examples/ python hello_world.py ``` -------------------------------- ### Initialize gclient Source: https://github.com/cztomczak/cefpython/wiki/BuildOnWindows Run the initial setup command to install required dependencies like git, svn, and python. ```bash gclient once ``` -------------------------------- ### Install wx toolkit on Ubuntu Source: https://github.com/cztomczak/cefpython/wiki/Download_CEF3_Linux Use this command to install the wx toolkit required for running the wxpython.py example. ```bash sudo apt-get install python-wxtools ``` -------------------------------- ### Hello World Example - CEF Python Initialization Source: https://github.com/cztomczak/cefpython/blob/master/docs/Tutorial.md Basic setup for CEF Python, including importing the module, setting an exception hook, initializing CEF, creating a browser, running the message loop, and shutting down. ```python from cefpython3 import cefpython as cef sys.excepthook = cef.ExceptHook def main(): cef.Initialize() cef.CreateBrowserSync(url="https://www.google.com/", # ... other parameters ) cef.MessageLoop() cef.Shutdown() if __name__ == '__main__': main() ``` -------------------------------- ### Install Pillow Image Library Source: https://github.com/cztomczak/cefpython/blob/master/docs/Tutorial.md Install the Pillow library, which is required for image manipulation in the screenshot example. ```text pip install Pillow ``` -------------------------------- ### Install Git Source: https://github.com/cztomczak/cefpython/wiki/BuildOnLinux Installs Git using apt-get and checks the installed version. Ensure you have an up-to-date version of Git. ```bash sudo apt-get install git git --version ``` -------------------------------- ### Install Cython Source: https://github.com/cztomczak/cefpython/wiki/BuildOnLinux Install Cython version 0.19.2 from PyPI. This requires downloading the source, extracting it, and running the setup script with sudo. ```bash sudo python setup.py install ``` -------------------------------- ### Locate installed package Source: https://github.com/cztomczak/cefpython/wiki/Download_CEF3_Windows Use this command to find the installation directory of the cefpython3 package to access the examples folder. ```bash pip show cefpython3 ``` -------------------------------- ### Install Linux build packages Source: https://github.com/cztomczak/cefpython/blob/master/docs/Build-instructions.md Initial package installation for Linux build environments. ```bash sudo apt-get install cmake g++ libgtk2.0-dev libgtkglext1-dev ``` -------------------------------- ### Create Setup Package Source: https://github.com/cztomczak/cefpython/wiki/BuildOnLinux Generate a setup package for CEF Python using the make-setup.py script, specifying the version. ```bash cd ~/cefpython/src/linux/installer/ python make-setup.py -v 31.0 ``` -------------------------------- ### Package the application Source: https://github.com/cztomczak/cefpython/blob/master/examples/pyinstaller/README-pyinstaller.md Execute the packaging script located in the examples directory to build the application. ```bash python pyinstaller.py ``` -------------------------------- ### PyQt/PySide CEF Integration Example Source: https://github.com/cztomczak/cefpython/blob/master/examples/README-examples.md This example covers embedding the CEF browser using PyQt4, PyQt5, and PySide libraries. Note: PyQt4 and PySide examples are currently broken on Linux. ```python # qt.py # example for PyQt4, PyQt5 and PySide libraries. # PyQt4 and PySide examples are currently broken on Linux, see [Issue #452](../../../issues/452). ``` -------------------------------- ### Install and Run CEF Python Snippets Source: https://github.com/cztomczak/cefpython/blob/master/examples/snippets/README-snippets.md Instructions for installing the cefpython3 package, cloning the repository, and running the javascript_bindings.py snippet. ```bash pip install cefpython3==66.0 git clone https://github.com/cztomczak/cefpython.git cd cefpython/examples/snippets/ python javascript_bindings.py ``` -------------------------------- ### Install Pip on OS X Source: https://github.com/cztomczak/cefpython/wiki/Download_CEF3_Mac If using the preinstalled Python on OS X and pip is not available, use this command to install pip. Subsequently, use 'sudo pip install cefpython3' to install the package. ```bash sudo easy_install pip ``` -------------------------------- ### Build Executable with PyInstaller Example Source: https://github.com/cztomczak/cefpython/blob/master/examples/README-examples.md An example demonstrating how to package a CEF Python application using the PyInstaller packager. This example currently supports only the Windows platform. ```python # pyinstaller/README-pyinstaller.md # example of packaging app using PyInstaller packager. Currently this example supports only Windows platform. ``` -------------------------------- ### pywin32 CEF Integration Example Source: https://github.com/cztomczak/cefpython/blob/master/examples/README-examples.md An example demonstrating the integration of the CEF browser with the pywin32 library on Windows. ```python # pywin32.py # example for pywin32 library ``` -------------------------------- ### Install Chromium Build Dependencies Source: https://github.com/cztomczak/cefpython/wiki/BuildOnLinux Run this script to install necessary build dependencies for Chromium. Use 'sudo' for installation. Answer 'No' to debug symbols and 'No' to the EULA for ttf-mscorefonts-installer to avoid font issues. ```bash cd ~/chromium/src/build/ sudo ./install-build-deps.sh --no-chromeos-fonts ``` -------------------------------- ### Install depot_tools Source: https://github.com/cztomczak/cefpython/wiki/BuildOnWindows Clone the Chromium tools repository to the local machine. ```bash git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git ``` -------------------------------- ### ResourceHandler and WebRequest Example Source: https://github.com/cztomczak/cefpython/blob/master/examples/README-examples.md An example demonstrating the implementation of ResourceHandler with WebRequest and WebRequestClient for modifying web requests. This example is found in the cefpython31 branch. ```python # wxpython-response.py # Example of implementing ResourceHandler with the use of WebRequest object and WebRequestClient interface to allow for reading/modifying web requests ``` -------------------------------- ### Example Usage of Screenshot Script Source: https://github.com/cztomczak/cefpython/blob/master/docs/Tutorial.md Demonstrates how to run the screenshot script with default or custom URL and viewport dimensions. ```text python screenshot.py ``` ```text python screenshot.py https://github.com/cztomczak/cefpython 1024 5000 ``` ```text python screenshot.py https://www.google.com/ncr 1024 768 ``` -------------------------------- ### Example Snippets Directory Source: https://github.com/cztomczak/cefpython/blob/master/src/cef_v59..v66_changes.txt A new directory 'examples/snippets/' has been added, containing various example Python scripts for different functionalities. ```python examples/snippets/onbeforeclose.py ``` ```python examples/snippets/network_cookies.py ``` ```python examples/snippets/mouse_clicks.py ``` ```python examples/snippets/javascript_bindings.py ``` ```python examples/snippets/javascript_errors.py ``` ```python examples/snippets/ondomready.py ``` ```python examples/snippets/onpagecomplete ``` -------------------------------- ### PyGObject / PyGI (GTK 3) CEF Integration Example Source: https://github.com/cztomczak/cefpython/blob/master/examples/README-examples.md This example shows how to embed the CEF browser using the PyGObject / PyGI library for GTK 3. Note: This example is currently broken on Mac. ```python # gtk3.py # example for PyGObject / PyGI library (GTK 3). Currently broken on Mac ([#310](../../../issues/310)). ``` -------------------------------- ### PySDL2 Off-screen Rendering Example Source: https://github.com/cztomczak/cefpython/blob/master/examples/README-examples.md An off-screen rendering example using the PySDL2 library. This example has reported issues, see Issue #324. ```python # pysdl2.py # off-screen rendering example for PySDL2 library. Example has some issues that are reported in Issue [#324](../../../issues/324). ``` -------------------------------- ### Install Cython with debug Python Source: https://github.com/cztomczak/cefpython/wiki/InternalDevelopment Installation command for Cython using the debug version of Python. ```bash cd Cython-0.19.2/ sudo python-dbg setup.py install ``` -------------------------------- ### Basic CEF Python Example Source: https://github.com/cztomczak/cefpython/blob/master/examples/README-examples.md A fundamental example demonstrating the core functionality of CEF Python. This example does not require any third-party GUI frameworks. ```python # hello_world.py # Basic example, doesn't require any third party GUI framework to run ``` -------------------------------- ### Install Linux build dependencies Source: https://github.com/cztomczak/cefpython/blob/master/docs/Build-instructions.md Execute this script to install missing packages required for building on Ubuntu systems. ```bash cd build/chromium/src/build/ chmod 755 install-build-deps.sh sudo ./install-build-deps.sh --no-chromeos-fonts --no-nacl --no-arm ``` -------------------------------- ### Install PyInstaller dependencies Source: https://github.com/cztomczak/cefpython/blob/master/examples/pyinstaller/README-pyinstaller.md Install the recommended version of PyInstaller and pycrypto to ensure compatibility and reduce anti-virus false positives. ```bash pip install --upgrade pyinstaller==3.2.1 pycrypto ``` -------------------------------- ### Install CEF Python via pip Source: https://github.com/cztomczak/cefpython/wiki/Download_CEF3_Windows Use this command to install the cefpython3 package from PyPI. ```bash pip install cefpython3 ``` -------------------------------- ### wxPython CEF Integration Example with High DPI Source: https://github.com/cztomczak/cefpython/blob/master/examples/README-examples.md This example demonstrates embedding the CEF browser using the wxPython toolkit and implements High DPI support on Windows. ```python # wxpython.py # example for wxPython toolkit. This example implements High DPI support on Windows. ``` -------------------------------- ### Install 64-bit Linux build dependencies Source: https://github.com/cztomczak/cefpython/blob/master/docs/Build-instructions.md Comprehensive list of packages required for 64-bit builds on Linux. ```bash sudo apt-get install bison build-essential cdbs curl devscripts dpkg-dev elfutils fakeroot flex g++ git-core git-svn gperf libapache2-mod-php5 libasound2-dev libav-tools libbrlapi-dev libbz2-dev libcairo2-dev libcap-dev libcups2-dev libcurl4-gnutls-dev libdrm-dev libelf-dev libexif-dev libffi-dev libgconf2-dev libgconf-2-4 libgl1-mesa-dev libglib2.0-dev libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libpci-dev libpulse-dev libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev libudev-dev libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev mesa-common-dev openbox patch perl php5-cgi pkg-config python python-cherrypy3 python-crypto python-dev python-psutil python-numpy python-opencv python-openssl python-yaml rpm ruby subversion ttf-dejavu-core ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho fonts-thai-tlwg wdiff wget zip ``` -------------------------------- ### Run build_all.bat script Source: https://github.com/cztomczak/cefpython/wiki/BuildOnWindows Executes the build script from the installer directory to generate distribution packages. ```batch cd src/windows/installer/ build_all.bat win32 31.2 ``` -------------------------------- ### Install 32-bit Linux build dependencies Source: https://github.com/cztomczak/cefpython/blob/master/docs/Build-instructions.md Comprehensive list of packages required for 32-bit builds on Linux. ```bash bison build-essential cdbs curl devscripts dpkg-dev elfutils fakeroot flex g++ git-core git-svn gperf libapache2-mod-php5 libasound2-dev libav-tools libbrlapi-dev libbz2-dev libcairo2-dev libcap-dev libcups2-dev libcurl4-gnutls-dev libdrm-dev libelf-dev libexif-dev libffi-dev libgconf2-dev libgl1-mesa-dev libglib2.0-dev libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libpci-dev libpulse-dev libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev libudev-dev libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev mesa-common-dev openbox patch perl php5-cgi pkg-config python python-cherrypy3 python-crypto python-dev python-psutil python-numpy python-opencv python-openssl python-yaml rpm ruby subversion ttf-dejavu-core ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho fonts-thai-tlwg wdiff wget zip lib32gcc1 lib32stdc++6 libc6-i386 linux-libc-dev:i386 libasound2:i386 libcap2:i386 libelf-dev:i386 libfontconfig1:i386 libgconf-2-4:i386 libglib2.0-0:i386 libgpm2:i386 libgtk2.0-0:i386 libgtk-3-0:i386 libncurses5:i386 libnss3:i386 libpango1.0-0:i386 libssl1.0.0:i386 libtinfo-dev:i386 libxcomposite1:i386 libxcursor1:i386 libxdamage1:i386 libxi6:i386 libxrandr2:i386 libxss1:i386 libxtst6:i386 ``` -------------------------------- ### Start Download Source: https://github.com/cztomczak/cefpython/wiki/ReleaseNotes Initiates a file download for a given URL. This method is part of the Browser object's interface for handling downloads. ```python browser.StartDownload(url) ``` -------------------------------- ### Off-screen Rendering Screenshot Example Source: https://github.com/cztomczak/cefpython/blob/master/examples/README-examples.md This example demonstrates off-screen rendering mode to capture a screenshot of a web page. Detailed discussion is available in the Tutorial's Off-screen rendering section. ```python # screenshot.py # Example of off-screen rendering mode to create a screenshot of a web page. ``` -------------------------------- ### Install CEF Python Package Source: https://github.com/cztomczak/cefpython/blob/master/tools/installer/cefpython3.README.txt Use this command to install the CEF Python 3 package. On Linux/Mac, prepend 'sudo' if using the system Python. ```bash python setup.py install ``` ```bash sudo python setup.py install ``` -------------------------------- ### Install additional Linux runtime packages Source: https://github.com/cztomczak/cefpython/blob/master/docs/Build-instructions.md Required packages for specific environments like chroot. ```bash sudo apt-get install libnss3 libnspr4 libxss1 libgconf-2-4 ``` -------------------------------- ### Define GDB automation commands Source: https://github.com/cztomczak/cefpython/wiki/InternalDevelopment Example content for a gdb.cmds file to automate debugger actions. ```text cy run quit ``` -------------------------------- ### Browser Get Setting Source: https://github.com/cztomczak/cefpython/blob/master/src/cef_v59..v66_changes.txt Introduces the Browser.GetSetting method for retrieving browser settings. ```python Browser.GetSetting ``` -------------------------------- ### Build CEF Client Example Source: https://github.com/cztomczak/cefpython/wiki/BuildOnWindows Open the 'cefclient2010.sln' solution located in the 'cef_binary/Release/' directory (or similar, depending on your build output) and build it in Release mode. ```bash cd chromium/src/cef/binary_distrib/cef_binary_xxxx_windows/ cefclient2010.sln ``` -------------------------------- ### Building Executables with PyInstaller Source: https://github.com/cztomczak/cefpython/blob/master/docs/Tutorial.md Information on using PyInstaller to build executable applications from CEF Python projects. By default, it packages the wxpython.py example. ```bash # PyInstaller example for building executable # (Specific command not provided in text) ``` -------------------------------- ### Build CEF Sample Applications Source: https://github.com/cztomczak/cefpython/blob/master/docs/Build-instructions.md Builds the 'cefclient', 'cefsimple', and 'ceftests' sample applications using Ninja. ```bash ninja cefclient cefsimple ceftests ``` -------------------------------- ### Get CEF Python Module Directory Source: https://github.com/cztomczak/cefpython/wiki/ReleaseNotes Use this function to retrieve the directory where the CEF Python module is installed. This is useful for locating resources or configuration files. ```python cefpython.GetModuleDirectory() ``` -------------------------------- ### Tkinter CEF Integration Example Source: https://github.com/cztomczak/cefpython/blob/master/examples/README-examples.md An example for integrating the CEF browser with Tkinter. Note: This example is currently broken on Mac. ```python # tkinter_.py # example for Tkinter. # Currently broken on Mac ([#309](../../../issues/309)). ``` -------------------------------- ### StartDownload Source: https://github.com/cztomczak/cefpython/blob/master/api/Browser.md Initiates a file download. ```APIDOC ## StartDownload ### Description Download the file at url using DownloadHandler. ### Parameters #### Request Body - **url** (string) - Required - The URL to download. ``` -------------------------------- ### Build libcef_dll_wrapper and cefclient Projects Source: https://github.com/cztomczak/cefpython/wiki/BuildOnLinux Build the libcef_dll_wrapper and cefclient projects. The libcef_dll_wrapper must be built first. ```bash cd ~/chromium/src/cef/binary_distrib/cef_binary_*/ make -j4 BUILDTYPE=Release libcef_dll_wrapper make -j4 BUILDTYPE=Release cefclient ``` -------------------------------- ### Check G++ Version Source: https://github.com/cztomczak/cefpython/wiki/BuildOnLinux Checks the installed G++ compiler version. Compiling works fine with G++ 4.6.3. Install using 'sudo apt-get install g++' if needed. ```bash g++ --version ``` -------------------------------- ### Automate Build with Spotify Binaries Source: https://github.com/cztomczak/cefpython/blob/master/docs/Build-instructions.md This command automates the process of downloading and preparing CEF binaries from Spotify's automated builds. It requires the --prebuilt-cef flag and will create a directory with the extracted binaries. ```bash python ../tools/automate.py --prebuilt-cef ``` -------------------------------- ### Check SVN Version Source: https://github.com/cztomczak/cefpython/wiki/BuildOnLinux Checks the installed Subversion (SVN) version. It should be 1.6.x to avoid potential issues during the build process. Install using 'sudo apt-get install subversion' if needed. ```bash svn --version ``` -------------------------------- ### Create Offscreen Browser Source: https://context7.com/cztomczak/cefpython/llms.txt Demonstrates how to create an offscreen browser instance for rendering web content without a visible window. Requires setting up window info and client handlers. ```python window_info = cef.WindowInfo() window_info.SetAsOffscreen(0) render_handler = RenderHandler() load_handler = LoadHandler(render_handler) browser = cef.CreateBrowserSync( window_info=window_info, url="https://www.google.com" ) browser.SetClientHandler(render_handler) browser.SetClientHandler(load_handler) browser.WasResized() # Trigger initial paint cef.MessageLoop() cef.Shutdown() ``` -------------------------------- ### Initialize CEF with settings and switches Source: https://context7.com/cztomczak/cefpython/llms.txt Configure application settings and command line switches before calling Initialize(). Must be executed before creating any browser windows. ```python from cefpython3 import cefpython as cef import sys # Set up exception handling for clean CEF shutdown sys.excepthook = cef.ExceptHook # Application settings configuration settings = { "debug": True, "log_severity": cef.LOGSEVERITY_INFO, "log_file": "debug.log", "cache_path": "webcache", # Persist cookies and local storage "user_agent": "MyApp/1.0", "remote_debugging_port": 8080, # Enable DevTools at http://127.0.0.1:8080 "windowless_rendering_enabled": False, } # Command line switches for Chromium switches = { "enable-media-stream": "", # Enable WebRTC "proxy-server": "socks5://127.0.0.1:8888", "disable-gpu": "", } # Initialize CEF with settings cef.Initialize(settings=settings, switches=switches) ``` -------------------------------- ### Initialize various browser window modes Source: https://context7.com/cztomczak/cefpython/llms.txt Demonstrates different configurations for browser windows including embedded, off-screen, popup, and default windowed modes. ```python # For embedding in a GUI framework (e.g., wxPython, PyQt) def create_embedded_browser(parent_window_handle, rect): window_info = cef.WindowInfo() # rect format: [left, top, right, bottom] window_info.SetAsChild(parent_window_handle, rect) return cef.CreateBrowserSync(window_info=window_info, url="https://example.com") # For off-screen rendering (headless) def create_offscreen_browser(parent_handle=0): cef.Initialize(settings={"windowless_rendering_enabled": True}) window_info = cef.WindowInfo() window_info.SetAsOffscreen(parent_handle) browser = cef.CreateBrowserSync(window_info=window_info, url="https://example.com") browser.WasResized() # Trigger initial render return browser # For popup window (Windows only) def create_popup_browser(parent_handle): window_info = cef.WindowInfo() window_info.SetAsPopup(parent_handle, "Popup Window") return cef.CreateBrowserSync(window_info=window_info, url="https://example.com") # Default windowed mode (no WindowInfo needed) cef.Initialize() browser = cef.CreateBrowserSync(url="https://example.com", window_title="Default") cef.MessageLoop() cef.Shutdown() ``` -------------------------------- ### Initialization and Settings Source: https://github.com/cztomczak/cefpython/blob/master/src/linux/binaries_64bit/kivy-select-boxes/readme.md How to initialize the selectBox plugin on select elements and configure its behavior. ```APIDOC ## jQuery selectBox Initialization ### Description Initializes the selectBox plugin on selected elements. Settings can be passed as an object during initialization or updated later. ### Parameters #### Request Body - **mobile** (Boolean) - Optional - Disables the widget for mobile devices (Default: false) - **menuTransition** (String) - Optional - The show/hide transition for dropdown menus: 'default', 'slide', 'fade' (Default: 'default') - **menuSpeed** (String) - Optional - The show/hide transition speed: 'slow', 'normal', 'fast' (Default: 'normal') - **loopOptions** (Boolean) - Optional - Flag to allow arrow keys to loop through options (Default: false) ### Request Example $('select').selectBox({ mobile: true, menuSpeed: 'fast' }); ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/cztomczak/cefpython/blob/master/docs/Build-instructions.md Installs the required Python dependencies for CEF Python from the 'requirements.txt' file. ```bash sudo pip install --upgrade -r ../tools/requirements.txt ``` -------------------------------- ### Install CEF Off-screen Rendering Dependency Source: https://github.com/cztomczak/cefpython/wiki/BuildOnLinux Install the libgtkglext1-dev package, which is a dependency for CEF off-screen rendering. ```bash sudo apt-get update sudo apt-get install libgtkglext1-dev ``` -------------------------------- ### Application Settings Initialization Source: https://github.com/cztomczak/cefpython/blob/master/api/ApplicationSettings.md Settings can be passed when calling cefpython.Initialize(). Additional settings can be configured via command line switches. ```APIDOC ## Introduction to Application Settings These settings can be passed when calling [cefpython](cefpython.md).Initialize(). The default values of options that are suggested in descriptions may not always be correct, it may be best to set them explicitily. There are hundreds of options that can be set through CEF/Chromium command line switches. These switches can be set programmatically by passing a dictionary with switches as second argument to [cefpython](cefpython.md).Initialize(). See the [CommandLineSwitches](CommandLineSwitches.md) wiki page for more information. Issue #244 is to add even more configurable settings by exposing API to Chromium Preferences. ``` -------------------------------- ### Create browser windows synchronously Source: https://context7.com/cztomczak/cefpython/llms.txt Use CreateBrowserSync to instantiate a browser window and load content from URLs, local files, or data URIs. ```python from cefpython3 import cefpython as cef # Initialize CEF first cef.Initialize() # Create a simple browser window navigating to a URL browser = cef.CreateBrowserSync( url="https://www.google.com/", window_title="My Browser" ) # Or load local file (note the file:// prefix) import pathlib local_path = pathlib.Path("index.html").absolute().as_uri() browser = cef.CreateBrowserSync(url=local_path, window_title="Local File") # Or load HTML content directly using data URI import base64 html_content = "