Create modern WinUI3-style desktop UIs in Python using pywebview and a Svelte frontend.
Project description
PyWebWinUI3
PyWebWinUI3 is a Windows desktop UI framework that combines:
- a Python backend
- a pywebview host window
- a Svelte frontend rendered inside Edge WebView2
- an XAML-like page format for declaring UI
The goal is to make desktop apps feel like WinUI3-style apps while still being driven from Python.
What It Does
PyWebWinUI3 lets you:
- declare pages in XAML-like markup
- bind controls to Python values
- react to value changes and lifecycle events from Python
- serve a bundled frontend from the Python runtime
- keep a Windows-style shell with theme and accent synchronization
At runtime, Python owns the application state, pywebview hosts the window, and the Svelte app renders the page tree loaded from the bundled frontend.
Platform
PyWebWinUI3 is currently aimed at Windows.
Runtime dependencies:
pywebviewhPyT
Installation
pip install PyWebWinUI3
Quick Start
from pywebwinui3.core import MainWindow
from pywebwinui3.type import Status
app = MainWindow("PyWebWinUI3")
app.addSettings("Settings.xaml")
app.addPage("Dashboard.xaml")
app.addPage("Test.xaml")
app.values["test_input"] = "Hello, world"
app.values["test_switch"] = False
@app.onValueChange("test_noticeSample")
def show_notice(*_):
app.notice(Status.Attention, "Title", "This is a sample notice")
app.start()
Minimal Page Example
<Page path="settings" icon="" name="Settings" title="Settings">
<Box>
<Horizontal>
<Text>App theme</Text>
<Space />
<Select value="system_theme">
<Option value="dark">Dark</Option>
<Option value="light">Light</Option>
<Option value="system">Use system setting</Option>
</Select>
</Horizontal>
</Box>
</Page>
Core Concepts
MainWindow
pywebwinui3.core.MainWindow is the main entry point.
Important methods:
addPage(...)addSettings(...)start(debug=False, hidden=False, on_top=None, width=None, height=None, min_width=900, min_height=600)notice(level, title, description, item=None)pin(state)syncValue(key, value)
values
app.values is the shared state dictionary between Python and the frontend.
Typical usage:
app.values["user_name"] = "Haruna"
app.values["is_enabled"] = True
app.values["progress"] = 50
The frontend reads these values directly, and user input writes back into the same store.
Built-in system values include keys such as:
system_titlesystem_iconsystem_themesystem_accentsystem_pagessystem_settingssystem_noficationsystem_pin
Events
MainWindow exposes decorator-style event hooks:
@app.onValueChange(key)@app.onAccentColorChange()@app.onSetup()@app.onExit()
Example:
@app.onValueChange("user_name")
def on_user_name_change(*_):
print(app.values["user_name"])
Notifications
Use app.notice(...) to push InfoBar-style messages into the frontend.
from pywebwinui3.type import Status
app.notice(Status.Success, "Saved", "Settings were saved successfully")
Status values:
Status.AttentionStatus.SuccessStatus.CautionStatus.CriticalStatus.Neutral
Markup Model
Pages are loaded into a JSON tree and rendered by the frontend.
Common tags currently implemented:
PageBoxHorizontalVerticalTextButtonInputSliderSwitchCheckRadioSelectOptionImageWebviewProgressbarLineSpaceExpenderIfMatchRepeat
Binding Model
PyWebWinUI3 supports two main binding styles:
- direct value binding through attributes like
value="test_input" - formatted text / expressions inside strings such as
{user_name}
The frontend compiles and caches formatted expressions, while Python remains the source of truth for state.
Path-like targets such as nested array access are also handled by the runtime value system when used by supported controls.
Resource Resolution
Relative resource paths are resolved from the Python caller's directory first, then from the packaged frontend bundle directory.
This lets you write things like:
- local XAML files via
addPage("Dashboard.xaml") - local images in markup
- bundled web assets shipped with the package
External URLs such as https://... and file://... are passed through as-is.
Window / Shell Behavior
The desktop shell is implemented with pywebview and provides:
- a hidden-title-bar host window
- theme and accent synchronization with Windows
- always-on-top pinning
- a pywebview API bridge between Python and the frontend
- direct bundled frontend hosting from
pywebwinui3/web/
Project Structure
PyWebWinUI3/
├─ pywebwinui3/
│ ├─ core.py # public API, app state, pywebview host
│ ├─ util.py # XAML loader, sync dict, accent watcher
│ ├─ event.py # event system
│ ├─ type.py # status and theme resource constants
│ └─ web/ # built frontend bundle shipped to users
├─ frontend/ # Svelte source
├─ example/ # sample application and XAML pages
└─ setup.py
Development Notes
If you are only using the package, you do not need to build the frontend manually.
If you are working on the framework itself:
- Python runtime code lives in
pywebwinui3/ - Svelte source lives in
frontend/ - the distributable frontend bundle lives in
pywebwinui3/web/
Example
See:
example/example.pyexample/Settings.xamlexample/Dashboard.xamlexample/Test.xaml
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pywebwinui3-1.2.2.tar.gz.
File metadata
- Download URL: pywebwinui3-1.2.2.tar.gz
- Upload date:
- Size: 3.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2d56f5969baf1bd133bc8114e5e2e1d55a4da2e958a806235db7baac9f3a895
|
|
| MD5 |
fe6c3fa57c785a433ce7c939f75ecc5f
|
|
| BLAKE2b-256 |
0e8e12548e5c8c80135f4bb7898d4d13af8bffd2f7a8982006c014a483422781
|
Provenance
The following attestation bundles were made for pywebwinui3-1.2.2.tar.gz:
Publisher:
deploy.yaml on Haruna5718/PyWebWinUI3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywebwinui3-1.2.2.tar.gz -
Subject digest:
f2d56f5969baf1bd133bc8114e5e2e1d55a4da2e958a806235db7baac9f3a895 - Sigstore transparency entry: 1864467745
- Sigstore integration time:
-
Permalink:
Haruna5718/PyWebWinUI3@f8ae483281d5e5846025ac53fac1864b00bc1871 -
Branch / Tag:
refs/tags/v1.2.2 - Owner: https://github.com/Haruna5718
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yaml@f8ae483281d5e5846025ac53fac1864b00bc1871 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pywebwinui3-1.2.2-py3-none-any.whl.
File metadata
- Download URL: pywebwinui3-1.2.2-py3-none-any.whl
- Upload date:
- Size: 3.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
810cee085ef0160debfc46f8d0ea39b5a6f721bda0f5059a4f77ceaa692a3ddd
|
|
| MD5 |
7bdf69205a4b285c21e34645ea84c596
|
|
| BLAKE2b-256 |
b045ba5fa67472b795f93c9b4194d565649812b47c7d2ac96eaf686a843a931d
|
Provenance
The following attestation bundles were made for pywebwinui3-1.2.2-py3-none-any.whl:
Publisher:
deploy.yaml on Haruna5718/PyWebWinUI3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywebwinui3-1.2.2-py3-none-any.whl -
Subject digest:
810cee085ef0160debfc46f8d0ea39b5a6f721bda0f5059a4f77ceaa692a3ddd - Sigstore transparency entry: 1864467831
- Sigstore integration time:
-
Permalink:
Haruna5718/PyWebWinUI3@f8ae483281d5e5846025ac53fac1864b00bc1871 -
Branch / Tag:
refs/tags/v1.2.2 - Owner: https://github.com/Haruna5718
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yaml@f8ae483281d5e5846025ac53fac1864b00bc1871 -
Trigger Event:
release
-
Statement type: