-
Notifications
You must be signed in to change notification settings - Fork 0
Label
Wire name label
Static text. It takes no focus, no input, and raises no events — the simplest trinket there is, and the one you reach for to caption everything else.
new label caption="Find what:"
| Property | Type | Default | Meaning |
|---|---|---|---|
caption |
string | — | Displayed text (may contain newlines). |
text_align |
left | center | right
|
— | Text alignment within the label. |
wrap |
flag | false |
Word-wrap text (enables height-for-width). |
Plus the common properties.
caption may contain newlines, which break lines whether or not wrap is
set. The caption is painted verbatim: no & mnemonic markup, no escapes.
label emits no events.
A label is not interactive. To make text that responds, use a Button — a flat one reads as a link.
Two different questions, which is why they are two names.
| Asks | |
|---|---|
text_align |
where the text sits inside the label |
align (common) |
where the label sits inside the space its parent gave it |
A label narrower than its slot with text_align=center centers its text
within the label's own box, which may itself be sitting at the left of the
row. If you want the text centered in the row, the label has to fill the row
— align=fill (the default) — or be centered as an item with align=center.
Without wrap, a label is one line per newline and takes whatever width that
needs. With wrap, it word-wraps and becomes height-for-width: its height
depends on how wide it ends up.
The same forty-three-character label:
| Width | Height |
|---|---|
| 80 units (10 columns) | 80 units (5 rows) |
| 160 units (20 columns) | 48 units (3 rows) |
That is what "enables height-for-width" means in the table — the layout asks
the label how tall it needs to be at the width it is about to get, instead
of using one fixed size hint. A wrapping label in a vbox therefore grows
taller when the window narrows, and the layout accounts for it.
Note that the reported size hint does not reflect wrapping; it stays the single-line width. The height-for-width query is what the layout actually uses.
Focus. None. A label is skipped by Tab and cannot be clicked into. It is the only one of the basic trinkets that takes no focus at all.
Accessibility. A label announces its text. Where a label captions another
trinket, that trinket usually wants its own acc_name too — the association
is visual, and a screen reader reading them in sequence is not the same as
knowing they belong together.
KittyTK — image/tty Trinket Kit · MIT licensed · alpha, 0.1.x
Repository · Issues · Support on ko-fi
Sibling projects: PurfecTerm (terminal emulator) · mew (text editor) · PawScript (language)
Getting Started
Installation Building from Source Running a Display Host Your First Application Examples
Protocol
Protocol Overview Object Model Properties and Values Events Templates and Aliases Common Properties Introspection Transports and Security
Clients
Go Client Python Client C Client
Application Objects
Application · MenuBar · Window · MessageBox
Output Trinkets
Label · ProgressBar · StatusBar
Input Trinkets
TextInput · Editor · Terminal
Button · CheckBox · RadioButton
ListView · ComboBox · TreeView
Layout Trinkets
TabTrinket · Panel
ScrollArea · MDIPane
Separator · Spacer · Splitter
Other Trinkets
Layout Helpers