Skip to content

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 →

Reference browserReference browser
  • In a Help tab or window of an app built on Pyzed, so its users can read the API offline.
  • With your own reference.Provider sections, 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)
Reference browser: A componentReference browser: A component
A component
Code
from pyzed import reference
ui.reference_browser(reference.Browser("pyzed.ui.badge"), sidebar_width=200)
Reference browser: A layout widgetReference browser: A layout widget
A layout widget
Code
from pyzed import reference
ui.reference_browser(reference.Browser("pyzed.row"), sidebar_width=200)

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

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

Full reference →