Skip to content

Dialog layer

Shows a dialog centered over base with a dimmed backdrop; clicking the backdrop calls on_dismiss. With dialog=None it returns base unchanged, so keep which dialog is open in your state and always wrap the view with it.

ui.dialog_layer · Category: Dialogs · Full reference →

Dialog layerDialog layer
  • Around your whole view, to show any of the dialogs on this page or a ui.modal.
import pyzed as pz
from pyzed import ui
class Files(pz.App):
def __init__(self):
self.asking = False
def close(self):
self.asking = False
def view(self):
dialog = None
if self.asking:
dialog = ui.confirm("Delete main.py?", self.delete, self.close, title="Delete file", danger=True)
return ui.dialog_layer(self.main_view(), dialog, on_dismiss=self.close)
Dialog layer: ui.alertDialog layer: ui.alert
ui.alert
Code
ui.dialog_layer(main_view(), ui.alert("Export finished.", on_close, kind="success", width=280))
Dialog layer: ui.modalDialog layer: ui.modal
ui.modal
Code
ui.dialog_layer(main_view(), ui.modal(ui.muted("Any content."), title="Modal", on_close=on_close,
width=280), on_dismiss=on_close)
Dialog layer: dialog=NoneDialog layer: dialog=None
dialog=None
Code
ui.dialog_layer(main_view(), None)

Dialog layer 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_dismiss () Sent when the backdrop 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 Files(pz.App):
def __init__(self):
self.asking = True
def close(self):
self.asking = False
def view(self):
dialog = ui.confirm("Delete main.py?", self.close, self.close, danger=True) if self.asking else None
return ui.dialog_layer(main_view(), dialog, on_dismiss=self.close) # click on the backdrop
dialog_layer(base, dialog=None, *, on_dismiss=None, theme=None)

Shows a dialog centered over base with a dimmed backdrop. With dialog=None it returns base unchanged, so it can always wrap the view. See Dialogs.

Property Default Description
base required The UI underneath.
dialog None A dialog from the functions below, or ui.modal.
theme None Theme to use instead of the current one (pyzed.theme.current()).

Events: on_dismiss (events).

Full reference →