Text
The base text widget: size, color, font, weight, italic, line_height, alignment and wrapping. In a themed UI prefer Label, which takes its color from the theme.
pz.text · Category: Content · Full reference →


pz.column([ pz.text("Pyzed", size=36, weight="bold", color="#74ade8"), pz.text("Fast, modern desktop UIs in Python.", size=16, color="#a9afbc"), pz.text("IBM Plex Mono, italic", font="IBM Plex Mono", italic=True, color="#e5c07b"),], spacing=6, align="center")When to use
Section titled “When to use”- For text with explicit styles, or custom fonts loaded with
pz.load_font.
import pyzed as pz
pz.column([ pz.text("Pyzed", size=36, weight="bold", color="#74ade8"), pz.text("Fast, modern desktop UIs in Python.", size=16, color="#a9afbc"), pz.text("IBM Plex Mono, italic", font="IBM Plex Mono", italic=True, color="#e5c07b"),], spacing=6, align="center")Variants
Section titled “Variants”

size=12Code
pz.text("Size 12", size=12)

size=18Code
pz.text("Size 18", size=18)

size=32Code
pz.text("Size 32", size=32)Font and weight
Section titled “Font and weight”

weight="bold"Code
pz.text("Bold", size=18, weight="bold")

weight="light"Code
pz.text("Light", size=18, weight="light")

italic=TrueCode
pz.text("Italic", size=18, italic=True)

font="mono"Code
pz.text("Monospace 0123", size=16, font="mono")Color and wrapping
Section titled “Color and wrapping”

color="#e5c07b"Code
pz.text("Golden text", size=18, color="#e5c07b")

width=, align_x="center"Code
pz.container(pz.text("A long sentence that wraps over several lines, centered.", align_x="center"), width=220)

line_height=1.8Code
pz.container(pz.text("Taller lines are easier to read in long paragraphs.", line_height=1.8), width=220)Events
Section titled “Events”Text 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”pz.text
Section titled “pz.text”text( content, *, size=None, color=None, font=None, weight=None, italic=False, line_height=None, align_x=None, align_y=None, width=None, height=None, wrap=True, selectable=None, selection_color=None,)A piece of text.
| Property | Default | Description |
|---|---|---|
content |
required | Content: a Widget, a string or a number (converted to text). |
size |
None |
Font size. |
color |
None |
Text or icon color. |
font |
None |
"sans" (IBM Plex Sans), "mono", "icons", "serif" or the name of a family loaded with load_font. |
weight |
None |
"thin", "light", "normal", "medium", "semibold", "bold", "black" or a number (100–900). |
italic |
False |
Italic. |
line_height |
None |
Line height relative to the size (1.0, 1.5…). |
align_x |
None |
Horizontal alignment: "start"/"left", "center", "end"/"right". |
align_y |
None |
Vertical alignment: "start"/"top", "center", "end"/"bottom". |
width |
None |
Width: pixels, "fill", "shrink" or "fill:N" (proportion). |
height |
None |
Height: pixels, "fill", "shrink" or "fill:N" (proportion). |
wrap |
True |
Line wrapping. With False the text doesn’t wrap. |
selectable |
None |
True lets the mouse select the text (drag, double-click a word, triple-click a block) and Ctrl+C copy it. A string names a selection group: the texts and Markdown of one group form a single selection, in the order they are drawn (the lines of a log, the messages of a chat). |
selection_color |
None |
Color behind the selected text. |