Skip to content

Resizable

A panel whose edge ("left", "right", "top" or "bottom") can be dragged to resize it, between min_size and max_size. It keeps the size the user drags it to; on_resize(size) is called when the drag ends so you can save it.

pz.resizable · Category: Layout · Full reference →

ResizableResizable
  • For one resizable sidebar or bottom panel next to fixed content.
import pyzed as pz
from pyzed import ui
t = pz.theme.current()
pz.row([
pz.resizable(pz.container(ui.label("Drag my right edge"), padding=12, width="fill", height="fill", bg=t.panel),
edge="right", size=260, min_size=160, color=t.border, hover_color=t.accent),
pz.container(ui.muted("Content"), center=True, width="fill", height="fill"),
], height="fill")
Resizable: edge="right"Resizable: edge="right"
edge="right"
Code
t = pz.theme.current()
pz.row([pz.resizable(pz.container(ui.label("Sidebar"), padding=10, width="fill", height="fill", bg=t.panel),
edge="right", size=150, color=t.border), pz.container(width="fill")], height="fill")
Resizable: edge="left"Resizable: edge="left"
edge="left"
Code
t = pz.theme.current()
pz.row([pz.container(width="fill"), pz.resizable(pz.container(ui.label("Inspector"), padding=10, width="fill",
height="fill", bg=t.panel), edge="left", size=150, color=t.border)], height="fill")
Resizable: edge="top"Resizable: edge="top"
edge="top"
Code
t = pz.theme.current()
pz.column([pz.container(height="fill"), pz.resizable(pz.container(ui.label("Console"), padding=10, width="fill",
height="fill", bg=t.panel), edge="top", size=80, color=t.border)], width="fill")

Resizable 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 = 260
def view(self):
return pz.row([
pz.resizable(ui.muted(f"{self.width:.0f} px"), edge="right", size=self.width, min_size=160,
on_resize=lambda size: setattr(self, "width", size)), # when the drag ends
main_view(),
], height="fill")
resizable(
content,
*,
edge='right',
size=240.0,
min_size=80.0,
max_size=None,
on_resize=None,
color=None,
hover_color=None,
thickness=1.0,
handle=8.0,
width=None,
height=None,
)

A panel whose edge can be dragged to resize it. It keeps the size the user drags it to; on_resize(size) is called when a drag ends so you can save it. Changing size later resets it.

Property Default Description
content required The panel’s content.
edge "right" The edge with the handle: "right" (a left sidebar), "left", "top" (a bottom panel) or "bottom".
size 240.0 Starting width (height for top/bottom edges).
min_size 80.0 Smallest size.
max_size None Largest size.
color None Line color.
hover_color None Line color while hovered or dragged.
thickness 1.0 Line thickness.
handle 8.0 Width of the area that can be grabbed.
width None Width for top/bottom edges.
height None Height for left/right edges.

Events: on_resize (events).

Full reference →