Skip to content

Repository files navigation

WebView2-for-Python

WebView2-for-Python is a pure Python binding to Microsoft Edge WebView2, a webview control for Windows 11 based on recent versions of Chrome/Chromium.

It can either be used in standalone mode or embedded into common GUI toolkits, simple wrappers are provided for the following toolkits:

Usage

Minimal code, standalone mode:

from webview2.standalone import *

webview = WebView2(url='https://www.google.com/')
webview.set_focus()
webview.run()

For the API check out __init__.py and the various demos.

Loader

The standard way to initialize WebView2 is to use the WebView2Loader.dll that comes with Microsofts's WebView2 SDK. WebView2-for-Python instead uses a custom loader.dll. The reason for this is that this small loader.dll allows to use CreateCoreWebView2EnvironmentWithOptions() and pass an instance of CoreWebView2EnvironmentOptions to it, which requires WRL and therefor is hardly possible to implement in plain C or Python/ctypes/libffi code. In particular the loader.dll activates support of browser extensions in the used environment.

Showcase projects

A first showcase project is LottieView, a simple and small desktop viewer/player for Lottie animation files.

Another showcase project is SimpleBrowser, still work in progress.

Screenshots

demo_standalone running in Windows 11 (dark mode)

About

WebView2 for Python in Windows

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages