Compared to others¶
Python has many GUI toolkits, and most are older and more complete than yugui. This page says what yugui does differently, where that helps, and when another toolkit is the better choice. In short: pick yugui if you want a desktop app whose state lives in one place and whose behaviour you can test without a window, and you can do without native-looking widgets, screen readers, mobile or the web, for now.
At a glance¶
| Draws with | Programming model | Runs on | |
|---|---|---|---|
| yugui | iced (its own widgets, on the GPU) | model, update, view (the Elm architecture) |
macOS, Linux |
| Tkinter | Tk | widget objects and callbacks | desktop |
| Qt (PySide6, PyQt6) | Qt | widget objects, signals and slots, or QML | desktop, some mobile |
| wxPython | the platform's own widgets | widget objects and events | desktop |
| GTK (PyGObject) | GTK | widget objects and signals | desktop, mainly Linux |
| Kivy | OpenGL (its own widgets) | widget objects, KV language | desktop, Android, iOS |
| Toga | the platform's own widgets | widget objects and callbacks | desktop, Android, iOS, web |
| Dear PyGui | the GPU, via Dear ImGui | items and callbacks | desktop |
| Flet | Flutter, in a client of its own | controls you change, then update | desktop, web, mobile |
| NiceGUI | a web browser | elements and callbacks, on a web server | browser, or a desktop window around one |
| Textual | the terminal | widgets, messages, reactive attributes | terminal, browser |
| turbodesk | the terminal | the view as a function of state, with hooks | terminal (macOS, Linux) |
| Plushie | iced, in a renderer process | model, update, view |
macOS, Linux, Windows |
What yugui does differently¶
The whole state is one value. In most toolkits, state is spread across widget objects: the text is in the entry, the checked state is in the checkbox, and your code keeps both in sync with its own data. In yugui, the model is the only state. view turns it into widgets, and the widgets turn clicks and keys into messages, which update turns into the next model. This is the Elm architecture, which the section below compares with the other ways of building an interface. Undo is keeping the previous models, a bug report can include the model, and there is no "the label didn't refresh" class of bug.
Tests go through the real widgets, without a window. yugui.testing.Driver lays the view out with iced, clicks where a user would click, types into the focused input, and runs your update. Tests take milliseconds and need no display, and they can save what the window would show as a PNG. Most toolkits need a display (or a virtual one) and a separate testing library for this.
iced runs inside your Python process. There is no second process and no protocol between your code and the widgets: a message can be any Python object, and an exception points at your code. yugui calls iced's own widget builders, so its widgets are iced's, drawn with the GPU.
Where yugui is weaker¶
- It's young. It isn't on PyPI yet, there are no Windows builds, and the API can still change.
- No accessibility. iced, which yugui draws with, doesn't talk to screen readers yet. If your users rely on one, use Qt, wxPython, GTK, Toga or Plushie.
- It doesn't look native. iced draws its own widgets, with its own themes. They look the same on every platform, and like no platform in particular.
- Fewer widgets. There's no built-in table, tree view, rich text editor, web view or video player, and no way to write a widget of your own in Python, beyond composing others or drawing on a canvas.
- No mobile and no web.
- No animations, and no hot reload.
Retained mode, immediate mode and the Elm architecture¶
Toolkits differ first in what they keep from one frame to the next.
Retained mode keeps a tree of widget objects. You build it once, then change it: set a label's text, add a row, disable a button. Tkinter, Qt, wxPython, GTK, Kivy, Toga and Textual work this way, and so does the browser's DOM. The toolkit only redraws what changed, but the state of the screen is spread across objects that any code holding one can change, and your own data has to be copied into them and kept in sync.
Immediate mode keeps almost nothing. On every frame, your code runs from the top and calls a function for each widget, which lays it out, draws it, and tells you on the spot whether it was clicked. The idea comes from game development; Dear ImGui made it popular, and imgui-bundle brings it to Python:
def gui():
global count
imgui.text(str(count))
if imgui.button("+"): # draws the button, and is True if it was clicked
count += 1
The Elm architecture shares immediate mode's main idea: the interface is described again from the current state, rather than kept and changed. But it splits the work in three. view describes the widgets as data, with the message each one sends; the runtime lays them out and draws them; when the user acts, the runtime passes the message to update, which returns the next state:
class Counter(ui.App[int]):
def init(self):
return 0
def update(self, count, message):
return count + 1 if message == "inc" else count
def view(self, count):
return ui.column(ui.text(count), ui.button("+", on_press="inc"))
Compared with immediate mode, the split changes four things:
- State changes in one place. In immediate mode, any widget call can change the state halfway through a frame, so the widgets drawn before it show the old value until the next frame. In the Elm architecture, only
updatechanges the state, one message at a time, and each frame shows a single state. - Layout sees the whole tree. An immediate mode toolkit places each widget when you call it, before it knows what comes next: centring something, or making a column as wide as its widest item, takes workarounds such as reusing the sizes measured on the previous frame. iced gets the whole tree before laying anything out.
- Behaviour can be tested without drawing.
updateis a function from a state and a message to the next state, andviewreturns data. In immediate mode, the behaviour lives inside the drawing calls, so a test has to run frames. - Nothing runs while nothing happens. Immediate mode toolkits usually redraw on every frame, which suits games and live displays. An Elm app runs
viewagain only after a message.
Immediate mode's advantage is brevity: a widget and what it does fit on one line, with no message and no update. That's why it's popular for debugging panels, game tools and internal tools, and why, for a small app, the Elm architecture can feel like ceremony.
Despite its name, Dear PyGui isn't immediate mode from Python: you create items and attach callbacks to them, as in retained mode.
Hooks, made popular by React, are a fourth approach. As in the Elm architecture, the view is a function of the state that returns a description of the interface. But each part of the view can keep its own state, in hooks that are matched from one run to the next by the order in which they are called, and input comes back through callbacks rather than messages. turbodesk works this way. The advantage is components: a text editor can keep its text, cursor and undo history to itself. In the Elm architecture, the state of a component you write yourself has to go into the app's model, and its messages through update. In return, the state is spread across the view again, and hooks come with rules: they must be called in the same order on every run, and a value changed in place may go unnoticed.
yugui uses the Elm architecture so that every change is a message, which you can print, log, replay or test. Its cost, threading a component's state through the model, is smaller than it sounds: iced keeps the internal state of its own widgets, such as focus, scroll positions and the cursor in a text input, so the cost only shows for components you write yourself.
Toolkit by toolkit¶
Tkinter¶
Tkinter comes with Python, it's stable, and it's small. For a short script that needs a dialog or a form, and must run wherever Python does, nothing beats it. Its widgets look dated next to modern apps, and larger Tkinter programs tend to tangle widget state with application state.
Choose yugui over Tkinter when the app is big enough that keeping state in sync gets hard, or when you want to test it.
Qt: PySide6 and PyQt6¶
Qt is the most complete toolkit you can use from Python: hundreds of widgets, item views for tables and trees, rich text, a web engine, printing, internationalisation, accessibility, a visual designer, and QML for animated interfaces. Its widgets follow each platform's style. It's also a large dependency, and its object model (widgets you create, mutate and connect with signals and slots) is the one yugui avoids. PySide6 is LGPL; PyQt6 is GPL or commercial.
Choose Qt for a large app that needs its breadth, accessibility, or a native look. Choose yugui for a smaller app where one model and headless tests matter more than the widget catalogue.
wxPython¶
wxPython wraps each platform's own widgets: Win32 on Windows, Cocoa on macOS, GTK on Linux. Apps look and behave natively, including for screen readers. The programming model is classic: widget objects and event handlers.
Choose wxPython when a native look and feel matters most.
GTK, with PyGObject¶
GTK is the toolkit of GNOME. With PyGObject, Python apps get GTK 4 and libadwaita, and fit perfectly on a GNOME desktop. It's well supported on Linux, harder to install and less polished on macOS and Windows.
Choose GTK for a Linux desktop app meant to feel at home in GNOME.
Kivy¶
Kivy draws its own widgets with OpenGL, handles touch and multi-touch, and runs on Android and iOS as well as on desktops. It has its own language, KV, to describe layouts.
Choose Kivy for touch interfaces and mobile. Choose yugui for a desktop app, where iced's widgets are closer to what users expect.
Toga¶
Toga, from the BeeWare project, gives Python apps native widgets on macOS, Windows, Linux, iOS and Android, and Briefcase packages them for each. Its widget set is smaller than Qt's, and like the toolkits above it uses widget objects and callbacks.
Choose Toga for native widgets on mobile and desktop from one codebase, and for its packaging.
Dear PyGui¶
Dear PyGui is built on Dear ImGui and draws everything on the GPU. It shines for tools: plots that update in real time, node editors, panels of sliders and values. It looks like a developer tool, which is what it's for.
Choose Dear PyGui for real-time plotting and internal tools. Choose yugui for an app that end users will see.
Flet¶
Flet lets you build Flutter interfaces from Python. The same app can run on the desktop, in a browser, or on a phone, with Flutter's Material widgets. Your Python code talks to a Flutter client, and in its classic style you change controls and then call update() to push the changes.
Choose Flet when you need the web or mobile as well as the desktop, or Flutter's widgets and animations.
NiceGUI¶
NiceGUI builds web interfaces from Python: your code runs a web server, and the interface is a page in a browser, or in a desktop window that embeds one. You get everything the web has (layout, rich content, charts) and the ability to use the app from another machine.
Choose NiceGUI for dashboards and tools used through a browser. Choose yugui for a desktop app that starts fast and doesn't carry a web engine.
Textual¶
Textual builds interfaces in the terminal, with widgets, CSS-like styles and mouse support, and it can also serve them to a browser. It's a different target: choose it when your users live in a terminal or connect over SSH.
turbodesk¶
turbodesk also builds terminal interfaces, but its model is close to yugui's. An app is a function that returns an immutable view of the whole screen, run again whenever something changes, and a test calls it and reads the screen as text. It keeps no widget objects, no CSS and no layout engine: views are grids of terminal cells, laid out with arithmetic, and widgets are Python functions, so new ones can be written from scratch. TurboVI, a vi clone built on it, draws every cell itself.
The main difference with yugui is where state lives. turbodesk uses hooks: a component such as its editor keeps its own state, and input reaches it through callbacks. yugui keeps all the state in one model, changed by messages. turbodesk is also pure Python, with Rich as its one dependency, where yugui needs a compiled extension.
Choose turbodesk for a terminal app that you want to write, and test, as a function of its state; choose Textual for a terminal app that needs more widgets, Windows or CSS. Choose yugui for a desktop window.
Plushie¶
Plushie is the closest relative: a Python library with the same Elm architecture, also drawn by iced. The difference is where iced runs. Plushie ships a precompiled renderer, a separate program written in Rust, and your Python code sends it the view over a pipe and receives events back. yugui compiles iced into a Python extension instead, so everything runs in one process.
Plushie's design gives it things yugui lacks: accessibility through AccessKit, animations that run in the renderer, hot reload, Windows support, a renderer that can run on another machine, and SDKs for Elixir, Gleam, Ruby and TypeScript that share it. It's on PyPI, and you never need a Rust toolchain.
yugui's design removes a layer instead. There is no protocol, so a message is any Python object rather than an event about a widget ID, and widgets don't need IDs at all. There is no renderer process to start, lose or reconnect to. And the test driver runs iced's widgets in your test process. Coming from Plushie maps one API to the other.
Choose Plushie today if you need accessibility, Windows, animations, or a stable package. Choose yugui if you prefer its simpler message model, and can live with what's missing.
iced, from Rust¶
You can also use iced directly, in Rust. You get all of it: custom widgets, shaders, every style option, compile-time checks of your messages, and a single executable to ship. You also get Rust's compile times and learning curve.
Choose iced if you know Rust, or the app needs custom widgets or the last bit of speed. Choose yugui to write the app in Python with iced's widgets, and to change it without recompiling. Coming from iced maps one to the other.