Python samples
September 10, 2026 ยท View on GitHub
All Python samples use generated bindings and an installed dynwinrt runtime.
Install dynwinrt and dynwinrt-codegen from PyPI, or build both from this
checkout, then run each sample's generate.ps1 before run.ps1.
| Sample | Demonstrates |
|---|---|
async-file-io | Temporary files, storage interfaces, and native asyncio |
ocr-image | Self-contained image creation, bitmap decoding, and Windows OCR |
app-lifecycle-single-instance | Multi-process activation redirection with Windows App SDK AppLifecycle |
cryptography | SHA-256, IBuffer, text encoding, and hex conversion |
interface-implementation | Standalone Python-backed WinRT interfaces, native IBackgroundTask calls, and multi-interface lifetime |
device-watcher | Device enumeration and thread-safe typed event subscriptions |
text-to-speech | asyncio, speech synthesis, media playback, and typed events |
app-notification | Windows App SDK bootstrap, notification builder, display, activation, and cleanup |
winui-hello-world | Minimal WinUI 3 XAML, controls, events, STA, and projected lifetime management |
custom-winmd-codegen | Generate, type, and import a Python package from an external WinMD |
winui-tic-tac-toe | XAML, a Python-defined WinUI control, native layout overrides, and Fluent resources |
winui-tic-tac-toe-code-only | A larger programmatic WinUI application without XAML |
The Windows App SDK samples require matching metadata, runtime packages, and a
bootstrap DLL. Their winapp.yaml configuration is already checked in, so
winapp restore prepares those inputs and the sample generate.ps1 creates
Python bindings from the resulting metadata lockfile. The stock Windows samples
auto-detect the newest installed Windows SDK Windows.winmd.