Skip to content

Stepper

Shows where the user is in a process of several steps. Done steps get a check, the current one is ringed and the line between them fills as you advance. on_select lets the user go back to a step.

ui.stepper · Category: Navigation · Full reference →

StepperStepper
  • For sign-ups, checkouts, installers and other wizards.
  • For sections the user can open in any order, use a Tab bar.
import pyzed as pz
from pyzed import ui
class Checkout(pz.App):
def __init__(self):
self.step = 0
def view(self):
return pz.column([
ui.stepper(["Cart", "Address", "Payment"], self.step, lambda i: setattr(self, "step", i)),
ui.button("Next", lambda: setattr(self, "step", min(self.step + 1, 3)), variant="solid"),
], spacing=16)
Stepper: HorizontalStepper: Horizontal
Horizontal
Code
pz.container(ui.stepper(["Cart", "Address", "Payment"], 1, on_step), width=420)
Stepper: vertical=TrueStepper: vertical=True
vertical=True
Code
ui.stepper([("Account", "Name and email"), ("Address", "Where it goes"), ("Payment", "Card or transfer")], 1, on_step, vertical=True)
Stepper: tint="success"Stepper: tint="success"
tint="success"
Code
pz.container(ui.stepper(["Upload", "Check", "Publish"], 3, on_step, tint="success"), width=420)
Stepper: errors=[1]Stepper: errors=[1]
errors=[1]
Code
pz.container(ui.stepper(["Cart", "Address", "Payment"], 1, on_step, errors=[1]), width=420)
Stepper: Not clickableStepper: Not clickable
Not clickable
Code
pz.container(ui.stepper(["One", "Two", "Three"], 0), width=420)

Stepper 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_select (index) Called with the index of a clicked step.

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 Checkout(pz.App):
def __init__(self):
self.step = 1
def go(self, index): # on_select: the index of the clicked step
self.step = index
def view(self):
return pz.column([
ui.stepper(["Cart", "Address", "Payment", "Done"], self.step, self.go),
ui.button("Next", lambda: self.go(min(self.step + 1, 4)), variant="solid"),
], spacing=16)
stepper(
steps,
current,
on_select=None,
*,
vertical=False,
linear=True,
errors=(),
tint='accent',
theme=None,
)

The steps of a wizard or a checkout: done ones get a check, the current one is ringed and the line between them fills as you advance.

Property Default Description
steps required Titles or (title, description) tuples.
current required Index of the step in progress (len(steps) once all are done).
vertical False Stacks the steps, with each description under its title.
linear True Only done steps and the current one can be clicked.
errors () Indexes of steps drawn in the error color.
tint "accent" Color of the done steps and the line.
theme None Theme to use instead of the current one (pyzed.theme.current()).

Events: on_select (events).

Full reference →