Skip to content

Shortcuts

A searchable, grouped list of key bindings for a Keyboard shortcuts dialog. groups are (title, [(action, keys), ...]) pairs.

ui.shortcuts · Category: Code and tools · Full reference →

ShortcutsShortcuts
  • Inside a ui.modal opened from a Help menu or with Ctrl+K Ctrl+S.
import pyzed as pz
from pyzed import ui
pz.container(ui.shortcuts([
("File", [("Save", "ctrl-s"), ("Open file", "ctrl-p")]),
("View", [("Command palette", "ctrl-shift-p"), ("Toggle left dock", "ctrl-b")]),
], on_query=on_query, height=240), width=420)
Shortcuts: GroupedShortcuts: Grouped
Grouped
Code
pz.container(ui.shortcuts([("File", [("Save", "ctrl-s"), ("Open", "ctrl-o")])], on_query=on_query, height=130),
width=360)
Shortcuts: query="pal"Shortcuts: query="pal"
query="pal"
Code
pz.container(ui.shortcuts([("View", [("Command palette", "ctrl-shift-p"), ("Zoom in", "ctrl-=")])],
query="pal", on_query=on_query, height=110), width=360)

Shortcuts 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_query (text) Adds a search box.

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 Help(pz.App):
def __init__(self):
self.query = ""
def view(self):
return ui.shortcuts([("File", [("Save", "ctrl-s"), ("Open file", "ctrl-p")])],
query=self.query, on_query=lambda q: setattr(self, "query", q)) # adds search
shortcuts(groups, *, query='', on_query=None, height=380, theme=None)

A searchable list of key bindings, grouped (for a Keyboard shortcuts dialog).

Property Default Description
groups required [(title, [(label, keys), ...]), ...], keys like "ctrl-s".
query "" Filter text.
height 380 Height of the list.
theme None Theme to use instead of the current one (pyzed.theme.current()).

Events: on_query (events).

Full reference →