Skip to content

Field

A form row like the ones of a settings screen: the title (and an optional description) on the left and any control on the right. Stack several in a column or a Settings group.

ui.field · Category: Forms · Full reference →

FieldField
  • For preferences and forms where each control needs a label and maybe a hint.
  • It lines up switches, selects and number fields of different widths.
import pyzed as pz
from pyzed import ui
pz.column([
ui.field("Autosave", ui.switch(True, on_toggle), description="Saves when you switch tabs"),
ui.field("Format on save", ui.checkbox(False, on_toggle)),
ui.field("Font size", ui.number_field(14, on_change, suffix="px")),
], spacing=14, width=440)
Field: SwitchField: Switch
Switch
Code
pz.container(ui.field("Autosave", ui.switch(True, on_toggle)), width=380)
Field: Number fieldField: Number field
Number field
Code
pz.container(ui.field("Font size", ui.number_field(14, on_change, suffix="px")), width=380)
Field: SelectField: Select
Select
Code
pz.container(ui.field("Theme", ui.select(["One Dark", "One Light"], "One Dark", on_select, width=150)), width=380)
Field: InputField: Input
Input
Code
pz.container(ui.field("Name", ui.input("Pyzed", on_input, width=180)), width=380)
Field: description=Field: description=
description=
Code
pz.container(ui.field("Autosave", ui.switch(True, on_toggle), description="Saves when you switch tabs"), width=380)
Field: error=Field: error=
error=
Code
pz.container(ui.field("Port", ui.number_field(80, on_change), error="Ports below 1024 need admin rights"), width=380)
Field: required=TrueField: required=True
required=True
Code
pz.container(ui.field("Name", ui.input("", on_input, width=180), required=True), width=380)
Field: vertical=TrueField: vertical=True
vertical=True
Code
pz.container(ui.field("Email", ui.input("ada@", on_input, invalid=True), vertical=True, required=True,
error="Enter a valid email"), width=320)

Field has no events of its own: it shows what you give it. 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.

field(
title,
control,
*,
description=None,
error=None,
required=False,
vertical=False,
theme=None,
)

A form row: title and description on the left, control on the right (like a settings screen).

Property Default Description
title required Title.
control required The control (switch, input…).
description None Help text.
error None A validation message shown under the title in the error color (see pz.validation_errors).
required False Adds a red * after the title.
vertical False Puts the control under the title.
theme None Theme to use instead of the current one (pyzed.theme.current()).

Full reference →