webview2
Build immersive applications supported by WebView2 on Windows Operation Systems
GUI Framework
Instead of WinForms and WPF, Use native Win32 directly.
The reason for choosing Win32 is that only the native API provides full control over window functionality, including achieving an immersive visual effect.
This project uses Win32 in a unique way: the core functionality is built with pywin32 to fully leverage Python’s capabilities.
For the WebView2 component, which exposes COM interfaces, we adopted a C++-wrapped DLL approach, supported by WebView2Window.
Because WebView2’s default rendering mode blocks interaction with the operating system, WebView2Window employs the Composition rendering mode.
In Composition mode, the WebView window achieves the same level of immersive styling as seen in applications like Visual Studio and JetBrains IDEs.
WebView2Window provides the following features:
- Frameless
- Shadow
- Resizeable
- Vertical Maximize
- Restrict client area to workspace when window maximized
- Minimize, maximize, restore and close buttons consistent with the behavior of system windows
Usage
import asyncio
from webview2 import Window, webview2_api
class MainWindow(Window):
@webview2_api
def greeting(self):
"""
JavaScript side invoke `await window.webview2.api.greeting()`
"""
return "hello webview2"
win = MainWindow(
title="My App", size="1480x960",# icon="logo.ico",
url="https://www.bing.com",# cache="PATH_OF_WEBVIEW2_CACHE"
)
asyncio.run(win.run())
Titlebar
Mark the css app-region:drag; of the title bar element to achieve the effect of dragging the title bar.
Release files for webview2 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| webview2-0.0.4.tar.gz | 144.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| webview2-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 287.4 kB
Release files / webview2-0.0.4.tar.gz
| Download URL | webview2-0.0.4.tar.gz |
|---|---|
| Size | 144.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9db829d9b73f26ab0acb3f81ca134859e34afe8659ce43ad684cd48c01f7e59d
|
|
BLAKE2b-256 checksum How to use checksums |
6b80e5b85e499f38804edd37e489b3c61b155ac8f1b3a4008448a2566684df92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|
Release files / webview2-0.0.4-py3-none-any.whl
| Download URL | webview2-0.0.4-py3-none-any.whl |
|---|---|
| Size | 143.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b16df9a76e38755e20086bf2f9c94adaf3d63120fe938bbf0721845a4c680b72
|
|
BLAKE2b-256 checksum How to use checksums |
efd9e1058030323938d39cfcf19f5bf7b2147d2a1280983a23c7dfb2ee09d0a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0
|