Reference browser
The built-in reference: a searchable class list (the library, your components and any section you reference.register) next to the page that is open, with back and forward, internal links and an Open online button. Keep a pyzed.reference.Browser in your state; the browser changes it. Links that leave the reference go to on_open_url. See Built-in reference.
ui.reference_browser · Category: Code and tools · Full reference →


from pyzed import reference
help = reference.Browser("pyzed.ui.button")ui.reference_browser(help, on_open_url=open_in_browser, sidebar_width=230)When to use
Section titled “When to use”- In a Help tab or window of an app built on Pyzed, so its users can read the API offline.
- With your own
reference.Providersections, as your app’s help.
from pyzed import ui
from pyzed import reference
help = reference.Browser("pyzed.ui.button")ui.reference_browser(help, on_open_url=open_in_browser, sidebar_width=230)Variants
Section titled “Variants”

Code
from pyzed import reference
ui.reference_browser(reference.Browser("pyzed.ui.badge"), sidebar_width=200)

Code
from pyzed import reference
ui.reference_browser(reference.Browser("pyzed.row"), sidebar_width=200)Events
Section titled “Events”Reference browser 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_open_url |
(url) |
Called with the URL of a link that leaves the reference (open it in the browser). |
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.
import webbrowser
from pyzed import reference
class Help(pz.App): def __init__(self): self.browser = reference.Browser("pyzed.ui.button")
def view(self): return ui.reference_browser(self.browser, on_open_url=webbrowser.open) # links to the webfrom dataclasses import dataclass
from pyzed import reference
@dataclassclass OpenUrl: url: str
class Help(pz.App): browser = reference.Browser("pyzed.ui.button")
def update(self, message): match message: case OpenUrl(url): print("open", url)
def view(self): return ui.reference_browser(self.browser, on_open_url=OpenUrl)from dataclasses import dataclass
from pyzed import reference
BROWSER = reference.Browser("pyzed.ui.button")
@dataclass(frozen=True)class State: last_url: str = ""
def view(state, set_state): return ui.reference_browser(BROWSER, on_open_url=lambda url: set_state(last_url=url))Properties and API
Section titled “Properties and API”ui.reference_browser
Section titled “ui.reference_browser”reference_browser( browser, *, on_open_url=None, sidebar_width=270, width='fill', height='fill', theme=None,)The built-in reference, like Godot’s: a searchable class list next to the page that is open.
Events: on_open_url (events).