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.

SampleDemonstrates
async-file-ioTemporary files, storage interfaces, and native asyncio
ocr-imageSelf-contained image creation, bitmap decoding, and Windows OCR
app-lifecycle-single-instanceMulti-process activation redirection with Windows App SDK AppLifecycle
cryptographySHA-256, IBuffer, text encoding, and hex conversion
interface-implementationStandalone Python-backed WinRT interfaces, native IBackgroundTask calls, and multi-interface lifetime
device-watcherDevice enumeration and thread-safe typed event subscriptions
text-to-speechasyncio, speech synthesis, media playback, and typed events
app-notificationWindows App SDK bootstrap, notification builder, display, activation, and cleanup
winui-hello-worldMinimal WinUI 3 XAML, controls, events, STA, and projected lifetime management
custom-winmd-codegenGenerate, type, and import a Python package from an external WinMD
winui-tic-tac-toeXAML, a Python-defined WinUI control, native layout overrides, and Fluent resources
winui-tic-tac-toe-code-onlyA 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.