Skip to content

yugui

yugui is a Python library for desktop apps with native windows. You describe the app as data and functions: a model holding its state, an update function that computes the next model when something happens, and a view function that shows the model as widgets. This is the Elm architecture.

The widgets come from iced, a GUI library written in Rust that draws on the GPU. yugui compiles iced into a Python extension module, so it runs inside your Python program: you install one package and write only Python.

import yugui as ui


class Counter(ui.App[int]):
    def init(self):
        return 0

    def update(self, count, message):
        match message:
            case "inc":
                return count + 1
            case "dec":
                return count - 1

    def view(self, count):
        return ui.column(
            ui.button("+", on_press="inc"),
            ui.text(count, size=40),
            ui.button("-", on_press="dec"),
            spacing=10,
            padding=20,
            align_x="center",
        )


ui.run(Counter())

The model is a number. Pressing a button sends its message, "inc" or "dec"; update returns the new number, and yugui calls view again to show it. Click through a session with the arrows:

What apps look like

Here are four of the examples. All the pictures on this site are taken by yugui's test driver, which runs the app without opening a window.

The 7GUIs spreadsheet

A spreadsheet, with formulas

iced's styling example

The standard widgets, under one of 22 themes

A clock drawn on a canvas

Drawing on a canvas

A color picker

Dragging on a canvas

The examples section has about thirty more, some with a recorded session to step through.

Why yugui

  • The state is in one place. Widgets don't hold state of their own that your code has to keep in sync: the model is the state, and the view is computed from it. Undo, saving and debugging all work on one value.
  • Messages are plain Python values. A message can be a string, a tuple or a dataclass, matched in update with match.
  • You can test without a window. yugui.testing.Driver clicks and types through iced's real widgets, in milliseconds, with no display.
  • One process, one package. No separate renderer program to install or keep running.

yugui is young: Compared to others says when a more established toolkit, such as Qt or Tkinter, is the better choice.

Where to go next

  • Get started: install yugui and write a first app.
  • Features: the widgets, events and tools yugui has today.
  • Guides: how yugui works, how to test apps, and how it maps to iced and Plushie if you know them.
  • Reference: every function, with its options.

Status

yugui is not on PyPI yet: you build it from a checkout, which needs Rust. It runs on macOS and Linux, with Python 3.12 or later.