Features¶
What yugui has today. Compared to others says what it doesn't have yet, and when another toolkit fits better.
The programming model¶
- Model, update, view. An app is three methods:
initreturns the first model,update(model, message)returns the next one, andview(model)returns the widgets that show it. See How yugui works. - Any Python value as the model: a number, a frozen dataclass, a dict. Mutable models work too: change the model in place and return nothing.
- Any Python value as a message.
ui.button("Save", on_press="save")sends the string"save". A widget that produces a value calls a handler with it:on_input=RenamesendsRename(text). - Setters, for the common case where a widget edits one field:
on_input=ui.set("address.city")stores the text in that field, with no message class to write. Paths are checked against the model when the view is built, so a typo fails at once. - Undo with
ui.History, which keeps past and future values of an immutable model. - Errors that don't crash the app. An exception in
updatekeeps the previous model; one inviewshows an error screen until the next view works.
Widgets¶
All of them are iced's, configured with keyword arguments. The API reference lists them with their options.
| Kind | Widgets |
|---|---|
| Layout | column, row, container, center, scrollable, grid, stack, pin, space, rule |
| Controls | button, checkbox, toggler, radio, slider, vertical_slider, pick_list, combo_box |
| Text | text, text_input, text_editor |
| Display | image, svg, progress_bar, tooltip |
| Pointer input | mouse_area, canvas (shapes you can click and hover) |
| Built from others | modal, popup, form, virtual_list and virtual_grid (which build only the rows in view) |
| Debugging | explain, which outlines the bounds of every widget inside it |
Every widget takes iced's sizes (pixels, "fill", "shrink"), paddings and alignments, and most take one of iced's named styles. There are 22 themes, from Light and Dark to Dracula, Nord and Tokyo Night.
Beyond the view¶
- Subscriptions: timers (
ui.every), key presses (ui.on_key), window events (ui.on_window), recomputed from the model after every update. - Keyboard shortcuts that apply while part of the view is shown:
ui.shortcuts(content, {"cmd+s": "save"}). Modals and popups close on Escape. - Tasks, returned by
update: move the focus, scroll, open file dialogs and alerts, quit, or run slow work on a background thread withui.perform. - Several windows, opened and closed from the model by
windows(model).
Testing¶
yugui.testing.Driver runs an app through iced's widgets without a window: it clicks, types, presses keys, scrolls, answers dialogs, completes background work, and saves the view as a PNG. Tests need no display and take milliseconds. Every picture on this site was taken that way. See Testing apps.
Examples¶
About thirty examples: all of the 7GUIs benchmark, from a counter to a spreadsheet; ports of iced's own examples; and ports of Plushie's demos, including a notes app with undo.