Skip to content

Build web and desktop apps in Python

Write components as .weft files, an XML template plus a Python code block. PyWeft runs them in the browser on real CPython compiled to WebAssembly, or in a native window with Python on your machine. No JavaScript to write, no build step.

Start the tutorial See the controls, live

app.weft
<template>
  <div>
    <h1>Hello, {{ name or "stranger" }}!</h1>
    <input @bind="name" placeholder="your name" />
    <button @click="count += 1">Clicked {{ count }} times</button>
  </div>
</template>

<code>
name: str = ""
count: int = 0
</code>

Type in the box and the heading follows; click and the count goes up.

State is plain Python fields. After every event PyWeft renders the component again, works out what changed and updates only that part of the page. There are no signals or observables to learn, and your code is ordinary Python that you can test without a browser.

Quick start

You need Python 3.10 or newer. With uv:

uv init myproject && cd myproject
uv add pyweft
uv run pyweft new myapp
uv run pyweft run myapp

Open http://127.0.0.1:8642/, then edit myapp/app.weft and save: the page updates in place and keeps what you'd typed. With pip, pip install pyweft, then pyweft new myapp and pyweft run myapp.

What you get

  • Components in one file


    Template, Python code and a <style> block that only applies to that component. Props, events, slots and @bind for composing them.

    Your first component

  • Web and desktop from one app


    pyweft build makes a static site any host can serve. pyweft run --desktop opens it in a native window, and pyweft build --desktop makes a program to hand out.

    Apps, building and desktop

  • Ready-made controls


    pyweft-ui: buttons, menus, chips, sliders, form fields with validation, autocomplete and input masks, date and range pickers, an event calendar, charts, tabs, sortable tables, dialogs, toasts, layout, and light and dark themes. No HTML or CSS needed.

    Try them live

  • Pages and shared state


    A pages/ folder becomes your app's screens, with links, Back and Forward. A Store holds what many components use.

    Pages and navigation

  • Async and background work


    async def handlers, and run_in_background() to run heavy Python in a Web Worker so the page never freezes.

    Async handlers

  • A fast dev loop


    Hot reload that keeps your app's state, readable errors that point to your .weft file and line, and a first screen that shows before Python has even started.

    Hot reload

Where next

  • New here? The tutorial builds a todo app step by step, in about fifteen minutes.
  • Looking something up? The guide covers every part of PyWeft, and the controls guide the toolkit.
  • Want to see it working first? Try the examples, running live in this browser.
  • Working with an AI assistant? Every app comes with an AGENTS.md that teaches it PyWeft, and pyweft check lets it find its own mistakes: see AI assistants.