Skip to content

Disclosure

A header with an arrow that shows or hides content. You own the open state: change it in on_toggle.

ui.disclosure · Category: Lists and menus · Full reference →

DisclosureDisclosure
  • To hide advanced options or details until they are needed.
import pyzed as pz
from pyzed import ui
class Form(pz.App):
def __init__(self):
self.advanced = False
def view(self):
return ui.disclosure("Advanced options", self.advanced_options(), open=self.advanced,
on_toggle=lambda: setattr(self, "advanced", not self.advanced))
Disclosure: open=FalseDisclosure: open=False
open=False
Code
pz.container(ui.disclosure("Advanced options", ui.muted("…"), open=False, on_toggle=on_toggle), width=300)
Disclosure: open=TrueDisclosure: open=True
open=True
Code
pz.container(ui.disclosure("Advanced options", ui.muted("Shown while open."), open=True,
on_toggle=on_toggle), width=300)
Disclosure: end=Disclosure: end=
end=
Code
pz.container(ui.disclosure("Environment", ui.muted("…"), open=False, on_toggle=on_toggle,
end=ui.badge("3")), width=300)

Disclosure 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_toggle () Message or callable when the header is clicked.

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 Form(pz.App):
def __init__(self):
self.advanced = False
def view(self):
return ui.disclosure("Advanced options", ui.muted("Proxy, timeouts…"), open=self.advanced,
on_toggle=lambda: setattr(self, "advanced", not self.advanced)) # no argument
disclosure(title, content, *, open, on_toggle=None, end=None, theme=None)

A collapsible section: a header with an arrow that shows or hides content. You own the open state: change it in on_toggle.

Property Default Description
title required Title (text or widget).
content required Content.
open required Whether it is open.
end None Widgets at the end (right).
theme None Theme to use instead of the current one (pyzed.theme.current()).

Events: on_toggle (events).

Full reference →