Panel
A dockable panel with an optional header. side decides which edge gets the border line; with a numeric width (height for the bottom) that edge can be dragged to resize it, and on_resize reports the new size.
ui.panel · Category: Workspace · Full reference →


pz.row([ ui.panel( pz.column([ui.list_item("Inbox", on_open, icon="inbox", selected=True, inset=True), ui.list_item("Archive", on_open, icon="archive", inset=True)]), header=ui.panel_header("Mail", [ui.icon_button("plus", on_new, size="xs")], icon="mail"), width=220, side="left", ), pz.container(ui.muted("Content"), center=True, width="fill", height="fill"),], height="fill")When to use
Section titled “When to use”- When you build your own layout instead of
ui.workspace: sidebars, inspectors, outlines.
import pyzed as pzfrom pyzed import ui
pz.row([ ui.panel( pz.column([ui.list_item("Inbox", on_open, icon="inbox", selected=True, inset=True), ui.list_item("Archive", on_open, icon="archive", inset=True)]), header=ui.panel_header("Mail", [ui.icon_button("plus", on_new, size="xs")], icon="mail"), width=220, side="left", ), pz.container(ui.muted("Content"), center=True, width="fill", height="fill"),], height="fill")Variants
Section titled “Variants”

side="left"Code
pz.row([ui.panel(ui.list_item("Inbox", icon="inbox", inset=True), header=ui.panel_header("Mail"), width=160, side="left"), pz.container(width="fill")], height="fill")

side="right"Code
pz.row([pz.container(width="fill"), ui.panel(ui.muted("Properties"), header=ui.panel_header("Inspector"), width=160, side="right")], height="fill")

side="bottom"Code
pz.column([pz.container(height="fill"), ui.panel(ui.terminal("$ ls"), header=ui.panel_header("Terminal"), height=100, side="bottom")], width="fill")Events
Section titled “Events”Panel has 1 event of its own, listed below. 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.
| Event | Handler gets | When |
|---|---|---|
on_resize |
(size) |
Called with the new size when a drag ends. |
Handler gets is what Pyzed passes to your callable: () means nothing. Any handler can also be a message (a value that is not callable), which goes to update().
Handling the events
Section titled “Handling the events”The same events written three ways. Imperative: methods of the app change self. Declarative: the handlers produce messages and one update() decides. Functional: a pure function draws an immutable state and asks for changes with set_state(...). See Imperative, declarative and functional.
class Mail(pz.App): def __init__(self): self.width = 220
def view(self): return pz.row([ ui.panel(ui.muted("Inbox"), header=ui.panel_header("Mail"), width=self.width, on_resize=lambda size: setattr(self, "width", size)), # when the drag ends main_view(), ], height="fill")from dataclasses import dataclass
@dataclassclass Width: size: float
class Mail(pz.App): width = 220
def update(self, message): match message: case Width(size): self.width = size
def view(self): return pz.row([ui.panel(ui.muted("Inbox"), width=self.width, on_resize=Width), main_view()], height="fill")from dataclasses import dataclass
@dataclass(frozen=True)class State: width: float = 220
def view(state, set_state): return pz.row([ui.panel(ui.muted("Inbox"), width=state.width, on_resize=lambda s: set_state(width=s)), main_view()], height="fill")Properties and API
Section titled “Properties and API”ui.panel
Section titled “ui.panel”panel( content, *, header=None, width=None, height=None, side='left', resizable=True, on_resize=None, min_size=120, theme=None,)A dockable panel. side decides which edge gets the border line; with a numeric width (height for the bottom) that border can be dragged to resize it.
| Property | Default | Description |
|---|---|---|
content |
required | Content: a Widget, a string or a number (converted to text). |
header |
None |
Header (ui.panel_header). |
width |
None |
Width: pixels, "fill", "shrink" or "fill:N" (proportion). |
height |
None |
Height: pixels, "fill", "shrink" or "fill:N" (proportion). |
side |
"left" |
"left", "right" or "bottom". |
resizable |
True |
False keeps the size fixed. |
min_size |
120 |
Smallest size when resizing. |
theme |
None |
Theme to use instead of the current one (pyzed.theme.current()). |
Events: on_resize (events).