Skip to content

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 →

WorkspaceWorkspace
  • As the root of editor-like apps: IDEs, note apps, database clients, file managers.
import pyzed as pz
from 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")]),
)
Workspace: Center and status barWorkspace: Center and status bar
Center and status bar
Code
ui.workspace(main_view(), status_bar=ui.status_bar([], [ui.status_item("Python")]))
Workspace: left=Workspace: left=
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)
Workspace: bottom=Workspace: bottom=
bottom=
Code
ui.workspace(main_view(), bottom=pz.column([ui.panel_header("Terminal", icon="terminal"),
ui.terminal("$ python main.py")]), bottom_height=90)
Workspace: right=Workspace: right=
right=
Code
ui.workspace(main_view(), right=pz.column([ui.panel_header("Outline"), ui.list_item("class Notes", icon="box")]),
right_width=150)
Workspace: title_bar=Workspace: title_bar=
title_bar=
Code
ui.workspace(main_view(), title_bar=ui.title_bar([ui.title_button("pyzed", chevron=True)],
[ui.avatar("KV")]))

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

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

Full reference →