Terminal
A read-only view that understands ANSI colors and stays scrolled to the end. Feed it the output of a process you run (for example with subprocess in a thread and pz.post). It also accepts lines of (text, color) segments; ui.ansi(text) converts ANSI text into those segments.
ui.terminal · Category: Code and tools · Full reference →


out = ("$ pytest -q\n\x1b[32m........................\x1b[0m\n\x1b[32m24 passed\x1b[0m in 1.21s\n" "$ maturin develop --release\n\x1b[2m Compiling pyzed v0.4.0\x1b[0m\n" "\x1b[32m✓\x1b[0m Installed pyzed-0.4.0\n$ ")pz.container(ui.terminal(out), width=560, height=190)When to use
Section titled “When to use”- To show build output, test runs, server logs or any command’s output.
import pyzed as pzfrom pyzed import ui
out = ("$ pytest -q\n\x1b[32m........................\x1b[0m\n\x1b[32m24 passed\x1b[0m in 1.21s\n" "$ maturin develop --release\n\x1b[2m Compiling pyzed v0.4.0\x1b[0m\n" "\x1b[32m✓\x1b[0m Installed pyzed-0.4.0\n$ ")pz.container(ui.terminal(out), width=560, height=190)Variants
Section titled “Variants”Content
Section titled “Content”

Code
pz.container(ui.terminal("$ ls\nmain.py notes.md pyproject.toml\n$ "), width=380, height=80)

Code
pz.container(ui.terminal("\x1b[32m✓\x1b[0m 24 passed \x1b[33m!\x1b[0m 1 warning \x1b[31m✗\x1b[0m 0 failed"), width=380, height=50)

font_size=16Code
pz.container(ui.terminal("$ python main.py\nHello", font_size=16), width=380, height=70)

Code
pz.container(ui.terminal([[("ok ", "#a1c181"), ("build", None)], [("err ", "#d07277"), ("lint", None)]]), width=380, height=60)Events
Section titled “Events”Terminal has no events of its own: it shows what you give it. Like every widget it also has the 18 common events (click, double_click, right_click, mouse_enter, drag, key_down, resize…), attached with .on(...): see Events and Events of every component.
Properties and API
Section titled “Properties and API”ui.terminal
Section titled “ui.terminal”terminal(lines, *, font_size=13, id=None, theme=None)A read-only terminal view with ANSI colors. It stays scrolled to the end.
| Property | Default | Description |
|---|---|---|
lines |
required | Text with ANSI escapes, or a list of lines of (text, color) segments. |
font_size |
13 |
Font size. |
id |
None |
Stable identifier used to focus or scroll it with a Command. |
theme |
None |
Theme to use instead of the current one (pyzed.theme.current()). |
ui.ansi
Section titled “ui.ansi”ansi(text)Converts text with ANSI colors into lines of (text, color_name) segments.
| Property | Default | Description |
|---|---|---|
text |
required | Text with ANSI escapes. |