Skip to content

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 →

PanelPanel
  • When you build your own layout instead of ui.workspace: sidebars, inspectors, outlines.
import pyzed as pz
from 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")
Panel: side="left"Panel: side="left"
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")
Panel: side="right"Panel: side="right"
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")
Panel: side="bottom"Panel: side="bottom"
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")

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().

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")
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).

Full reference →