Skip to content

Window frame

Draws the whole frame of a window opened without system decorations (frame = "custom"): a title bar that moves the window (double click maximizes), the minimize, maximize and close buttons in the style of a platform, menus on the left (ui.Menu) and borders that resize the window. ui.window_title_bar is the bar alone, ui.window_controls the three buttons and ui.system_platform() says which style this system uses.

ui.window_frame · Category: Workspace · Full reference →

Window frameWindow frame
  • For apps that want a modern editor-like window: menus and pickers in the title bar instead of the system’s frame. See Window frames.
  • With no callbacks, ui.window_title_bar and ui.window_controls only show: use them to preview a window in the frame of each platform.
import pyzed as pz
from pyzed import ui
class Notes(pz.App):
title = "Notes"
frame = "custom" # or "macos", "windows", "gnome", "ubuntu", "kde"
def view(self):
return ui.window_frame(
self.editor(),
menus=[ui.Menu("File", [ui.MenuItem("Open…", self.open, keys="ctrl-o"), ui.SEPARATOR,
ui.MenuItem("Quit", self.close)])],
start=[ui.title_button("pyzed", chevron=True)],
end=[ui.button("Run", self.run, icon="play", size="sm")],
)
Window frame: style="windows"Window frame: style="windows"
style="windows"
Code
pz.container(ui.window_title_bar("notes.py", style="windows"), width=420)
Window frame: style="macos"Window frame: style="macos"
style="macos"
Code
pz.container(ui.window_title_bar("notes.py", style="macos"), width=420)
Window frame: style="gnome"Window frame: style="gnome"
style="gnome"
Code
pz.container(ui.window_title_bar("notes.py", style="gnome"), width=420)
Window frame: style="kde"Window frame: style="kde"
style="kde"
Code
pz.container(ui.window_title_bar("notes.py", style="kde"), width=420)
Window frame: style="ubuntu"Window frame: style="ubuntu"
style="ubuntu"
Code
pz.container(ui.window_title_bar("notes.py", style="ubuntu"), width=420)
Window frame: focused=FalseWindow frame: focused=False
focused=False
Code
pz.container(ui.window_title_bar("notes.py", style="windows", focused=False), width=420)
Window frame: maximized=TrueWindow frame: maximized=True
maximized=True
Code
ui.window_controls("windows", maximized=True)
Window frame: ui.window_controls("macos")Window frame: ui.window_controls("macos")
ui.window_controls("macos")
Code
ui.window_controls("macos")

Window frame has 5 events 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 Of Handler gets When
on_drag ui.window_title_bar () Called when the empty part of the bar is dragged (return Command.drag_window()).
on_minimize ui.window_title_bar, ui.window_controls () Minimize button.
on_maximize ui.window_title_bar, ui.window_controls () Maximize button and double click on the bar.
on_close ui.window_title_bar, ui.window_controls () Close button.
on_menu ui.window_title_bar () Right click on the bar.

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 Notes(pz.App):
frame = "custom" # Pyzed draws the title bar
def view(self):
bar = ui.window_title_bar(
"notes.py",
on_drag=lambda: self.drag(), # the empty part of the bar
on_minimize=lambda: self.minimize(),
on_maximize=lambda: self.toggle_maximize(), # also a double click on the bar
on_close=lambda: self.close(),
on_menu=lambda: print("window menu"), # right click on the bar
maximized=self.window_maximized,
)
return pz.column([bar, main_view()])
window_frame(
content,
*,
title=None,
menus=None,
menu_button=True,
start=(),
center=None,
end=(),
style=None,
window=None,
height=None,
resize_border=6.0,
resize_edges=True,
bg=None,
theme=None,
)

The whole frame of a window opened with frame="custom": a title bar that moves the window (double click maximizes, right click opens the system menu on Windows), the minimize, maximize and close buttons in the style of a platform, menus on the left, and borders that resize the window.

Property Default Description
content required The window’s content, under the title bar.
title None Title shown in the bar. By default the window’s title.
menus None Menus on the left of the bar: a list of ui.Menu.
menu_button True Shows the menus behind a ☰ button (False always shows their names).
start () Items after the menus (project, branch…).
center None Your own widget in the middle instead of the title (a search field, Run and Stop…); the bar still drags on both sides of it.
end () Items before the window buttons.
style None "macos", "windows", "gnome", "ubuntu" or "kde". By default the window’s frame, or this system’s.
window None The window the buttons act on. By default the one whose view() is running.
height None Height of the bar. By default the platform’s.
resize_border 6.0 Width in pixels of the borders that resize the window.
resize_edges True False leaves the resize borders to you (pz.window_edges), to put them over menus and dialogs.
bg None Background color ("#rrggbb[aa]", (r, g, b[, a]) or "transparent").
theme None Theme to use instead of the current one (pyzed.theme.current()).

Full reference →

@dataclass
class Menu(label, items=[])

A menu of a window frame’s menu bar: a name and its items (ui.MenuItem, ui.SEPARATOR or a header string).

Property Default Description
label required The menu’s name.
items [] Its entries: ui.MenuItem, ui.SEPARATOR or a header string.

Full reference →

window_title_bar(
title=None,
*,
style=None,
start=(),
center=None,
end=(),
on_drag=None,
on_minimize=None,
on_maximize=None,
on_close=None,
on_menu=None,
maximized=False,
focused=True,
width='fill',
height=None,
bg=None,
border=True,
theme=None,
)

A window’s title bar alone: window buttons in the style of style (on the left for macOS), start items, the title and end items. Without callbacks it only shows, which is how Pyzed Design previews a form in the frame of each platform.

Property Default Description
title None Title (centered, or on the left on Windows).
style None "macos", "windows", "gnome", "ubuntu" or "kde" (None: this system’s).
start () Items at the start.
center None Widget in the middle instead of the title; the bar still drags on both sides of it.
end () Items at the end.
maximized False Shows the restore symbol.
focused True False dims it like a window in the background.
width "fill" Width: pixels, "fill", "shrink" or "fill:N" (proportion).
height None Height. By default the platform’s.
bg None Background color ("#rrggbb[aa]", (r, g, b[, a]) or "transparent").
border True Line under the bar.
theme None Theme to use instead of the current one (pyzed.theme.current()).

Events: on_drag, on_minimize, on_maximize, on_close, on_menu (events).

Full reference →

window_controls(
style=None,
*,
on_minimize=None,
on_maximize=None,
on_close=None,
maximized=False,
focused=True,
height=None,
theme=None,
)

The minimize, maximize and close buttons in the style of a platform. A button without a callback is drawn but does nothing.

Property Default Description
style None "macos", "windows", "gnome", "ubuntu" or "kde" (None: this system’s).
maximized False Shows the restore symbol.
focused True False dims them.
height None Height.
theme None Theme to use instead of the current one (pyzed.theme.current()).

Events: on_minimize, on_maximize, on_close (events).

Full reference →

system_platform()

The style of this system’s window buttons: "macos", "windows", "kde", "ubuntu" or "gnome" (other Linux desktops). Under WSL it is "windows".

Full reference →