Workspace
Builds the frame of an editor-style window: the title bar on top, docks on the left, right and bottom, the center and the status bar. Pass None to hide a dock (that is how Ctrl+B works); left_width, right_width and bottom_height set their size and on_resize reports drags.
ui.workspace · Category: Workspace · Full reference →


files = ui.TreeNode.from_paths(["src/main.py", "src/ui.py", "README.md"], status={"src/ui.py": "modified"})ui.workspace( pz.column([ ui.tab_bar([ui.Tab.for_file("src/main.py")], "src/main.py", on_close=on_close), ui.editor("ws-main", "import pyzed as pz\n\n\ndef main():\n pz.run(App)\n", path="main.py"), ]), title_bar=ui.title_bar([ui.title_button("pyzed", chevron=True), ui.title_button("main", icon="git-branch", muted=True)], [ui.icon_button("bell", on_bell, size="sm"), ui.avatar("KV")]), left=pz.column([ui.panel_header("Project", [ui.icon_button("plus", on_new, size="xs")]), ui.tree(files, expanded={"src"}, selected="src/main.py")]), bottom=pz.column([ui.panel_header("Terminal", icon="terminal"), ui.terminal("$ python main.py\n\x1b[32m✓\x1b[0m done")]), status_bar=ui.status_bar([ui.status_item("0", icon="circle-x"), ui.status_item("1", icon="triangle-alert")], [ui.status_item("Ln 4, Col 8"), ui.status_item("Python")]), left_width=200, bottom_height=110,)When to use
Section titled “When to use”- As the root of editor-like apps: IDEs, note apps, database clients, file managers.
import pyzed as pzfrom pyzed import ui
class Ide(pz.App): def __init__(self): self.show_left = True
def on_key(self, combo): if combo == "ctrl-b": self.show_left = not self.show_left
def view(self): return ui.workspace( self.editor_area(), title_bar=ui.title_bar([ui.title_button("my-project", chevron=True)]), left=self.project_panel() if self.show_left else None, status_bar=ui.status_bar([], [ui.status_item("Python")]), )Variants
Section titled “Variants”

Code
ui.workspace(main_view(), status_bar=ui.status_bar([], [ui.status_item("Python")]))

left=Code
ui.workspace(main_view(), left=pz.column([ui.panel_header("Project"), ui.list_item("main.py", icon="file-code", selected=True, inset=True)]), left_width=150)

bottom=Code
ui.workspace(main_view(), bottom=pz.column([ui.panel_header("Terminal", icon="terminal"), ui.terminal("$ python main.py")]), bottom_height=90)

right=Code
ui.workspace(main_view(), right=pz.column([ui.panel_header("Outline"), ui.list_item("class Notes", icon="box")]), right_width=150)

title_bar=Code
ui.workspace(main_view(), title_bar=ui.title_bar([ui.title_button("pyzed", chevron=True)], [ui.avatar("KV")]))Events
Section titled “Events”Workspace 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 |
(side, size) |
Called with (side, size) when the user finishes resizing a dock by dragging its inner border. |
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 Ide(pz.App): def __init__(self): self.left_width, self.bottom_height = 220, 160
def resized(self, side, size): # on_resize: which dock and its new size if side == "left": self.left_width = size elif side == "bottom": self.bottom_height = size
def view(self): return ui.workspace(main_view(), left=ui.panel_header("Project"), bottom=ui.panel_header("Terminal"), left_width=self.left_width, bottom_height=self.bottom_height, on_resize=self.resized)from dataclasses import dataclass
@dataclassclass Resized: side: str size: float
class Ide(pz.App): sizes = {"left": 220, "bottom": 160}
def update(self, message): match message: case Resized(side, size): self.sizes = {**self.sizes, side: size}
def view(self): return ui.workspace(main_view(), left=ui.panel_header("Project"), bottom=ui.panel_header("Terminal"), left_width=self.sizes["left"], bottom_height=self.sizes["bottom"], on_resize=Resized)from dataclasses import dataclass
@dataclass(frozen=True)class State: left: float = 220 bottom: float = 160
def view(state, set_state): return ui.workspace(main_view(), left=ui.panel_header("Project"), bottom=ui.panel_header("Terminal"), left_width=state.left, bottom_height=state.bottom, on_resize=lambda side, size: set_state(**{side: size}))Properties and API
Section titled “Properties and API”ui.workspace
Section titled “ui.workspace”workspace( center, *, title_bar=None, left=None, right=None, bottom=None, status_bar=None, left_width=240, right_width=320, bottom_height=220, on_resize=None, theme=None,)The layout of an editor-style window: title bar, left, right and bottom docks, center and status bar. Pass None to hide a dock.
| Property | Default | Description |
|---|---|---|
center |
required | Central content (usually tabs + editor). |
title_bar |
None |
Title bar (ui.title_bar). |
left |
None |
Left dock. |
right |
None |
Right dock. |
bottom |
None |
Bottom dock. |
status_bar |
None |
Status bar (ui.status_bar). |
left_width |
240 |
Width of the left dock. |
right_width |
320 |
Width of the right dock. |
bottom_height |
220 |
Height of the bottom dock. |
theme |
None |
Theme to use instead of the current one (pyzed.theme.current()). |
Events: on_resize (events).