-
Notifications
You must be signed in to change notification settings - Fork 0
Panel
Wire name panel
A container. It holds children, optionally lays them out, and optionally draws a border around them. Almost every window has one immediately inside it, and almost every example on this wiki starts with one.
p=new panel layout=vbox spacing=0 children={
new label caption="Name:"
new textinput placeholder="…"
}
| Property | Type | Default | Meaning |
|---|---|---|---|
border |
flag | false |
Draw a border around the panel |
border_style |
single | double | rounded | heavy | ascii
|
— | Border line style |
fixed_width |
int | — | Fixed panel width in units |
layout |
vbox | hbox | none
|
— | Child layout manager |
spacing |
int | — | Spacing between laid-out children |
Plus the common properties.
panel emits no events.
A panel is structure, not a control. It takes no focus and reports nothing; its children do that.
Properties apply in the order they are written, and two of a panel's interact.
layout before spacing. Spacing belongs to the layout manager, so
there has to be one first. Out of order it is a plain error, not a silent
no-op:
new panel spacing=1 layout=vbox
-> spacing: set layout before spacing
children before anything that indexes them. That rule is not a panel's
own, but it bites here because children={…} is a panel property like any
other — see ListView for what it costs on a trinket that has a
selected.
A panel has no layout manager until you give it one. A child added to a
panel with no layout= keeps the bounds it had, which is nothing:
new panel children={ new label caption="x" } # child ends up 0×0 at 0,0
That is by design — layout=none is a supported choice for a panel whose
children are positioned some other way — but it is also the most common
reason a panel comes out empty. If children do not appear, check for a
missing layout=.
layout |
Children are |
|---|---|
vbox |
stacked top to bottom |
hbox |
placed left to right |
none |
left where they are — the same as omitting layout
|
Flex and grid exist in the layout engine but have no wire spelling yet;
layout=grid is rejected with a message saying so.
The layout reads each child's own stretch and align,
so a row of controls with one stretched item is the usual shape:
p=new panel layout=hbox spacing=1 children={
new label caption="Search:"
new textinput stretch=1
new button caption="Go"
}
spacing is in units, so spacing=1 is an eighth of a
column at the default denomination — for a gap of one character use
spacing=8, or re-denominate the panel.
fixed_width pins the panel's own width and takes it out of the parent's
stretch arithmetic.
A layout you build more than once belongs in a template, which can carry the panel's properties and its children together:
template FormRow=panel layout=hbox spacing=8 children={
lbl=new label caption="?"
input=new textinput stretch=1
}
name=new FormRow
email=new FormRow
Each instance can then override what differs — name.lbl and email.lbl
are reachable by surfacing them.
border draws a frame, and border_style picks the line. The frame is drawn
inside the panel's bounds and insets the children by a cell on each side,
so a bordered panel needs a cell more room in each direction than its contents
require.
border_style=ascii is the one to reach for when the output may be read by
something that cannot be trusted with box-drawing characters; the rest —
single double rounded heavy — need a terminal font with them.
Common Properties — stretch, align, units ·
Splitter — two panes the user can resize ·
ScrollArea — a container larger than its window
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