This is the smallest WinUI 3 sample in the repository. It complements the Tic-Tac-Toe samples by showing only the setup required to:
- bootstrap the Windows App SDK;
- enter a single-threaded WinRT apartment;
- load a small XAML fragment;
- project raw XAML objects with
project_as(); - pass a generated
StackPaneldirectly to the baseUIElementAPI; - create and activate a
Window; - subscribe to
Button.Click; and - release projected objects before leaving the apartment.
The flow is intentionally comparable to PyWinRT's WinUI 3 Hello World, while using dynwinrt's generated bootstrap and lifetime APIs.
- WinApp CLI 0.6.2 or newer;
dynwinrtinstalled in the selected Python interpreter; anddynwinrt-codegenonPATH, or passed with-Codegen.
winapp restore
.\generate.ps1 -Codegen ..\..\..\target\release\dynwinrt-codegen.exe
.\run.ps1 -Python C:\path\to\python.exe -Major 2 -Minor 3winapp restore prepares the pinned SDK metadata and bootstrap binaries under
.winapp\. generate.ps1 uses that metadata to generate Python bindings and
copies the selected architecture's bootstrap DLL to .runtime\.
Major and Minor default to 2 and 3. They must exactly match the Windows
App SDK product version represented by the metadata, bootstrap DLL, and
installed runtime.
Use -Smoke to create the window and controls, update the text once, print
python-winui-hello-ok, and exit automatically.
The runtime keeps a single owned reference to the WinUI XAML implementation
DLL from its first use until process termination, including cleanup on MTA
threads that outlive the UI apartment. This does not replace the sample's
event unsubscription, projected object release, or balanced RoApartment.
The DLL and its module-level static state are not unloaded when the window
closes; in-process WinUI module unloading/hot replacement is not supported.
See Python WinUI lifetime policy.