Skip to content

Timeline

A vertical list of what happened, joined by a line: each ui.TimelineItem has a title, an optional time, description and icon in its dot. on_press makes the entries clickable.

ui.timeline · Category: Data · Full reference →

TimelineTimeline
  • For the history of an order, a ticket or a file, or a changelog.
  • For the steps still to come, use a Stepper.
import pyzed as pz
from pyzed import ui
pz.container(ui.timeline([
ui.TimelineItem("Order placed", "We got your order.", time="09:12", icon="shopping-cart"),
ui.TimelineItem("Shipped", "On its way with the courier.", time="14:30", icon="truck"),
ui.TimelineItem("Delivered", time="Tomorrow", icon="package-check", tint="success"),
]), width=360)
Timeline: Titles onlyTimeline: Titles only
Titles only
Code
pz.container(ui.timeline(["Created", "Reviewed", "Merged"]), width=300)
Timeline: icon=, time=Timeline: icon=, time=
icon=, time=
Code
pz.container(ui.timeline([ui.TimelineItem("Commit pushed", time="2 min ago", icon="git-commit-horizontal"), ui.TimelineItem("Checks passed", time="1 min ago", icon="check", tint="success")]), width=340)
Timeline: dense=TrueTimeline: dense=True
dense=True
Code
pz.container(ui.timeline([ui.TimelineItem("Started", time="10:00"), ui.TimelineItem("Paused", time="10:20", tint="warning"), ui.TimelineItem("Finished", time="11:05", tint="success")], dense=True), width=300)
Timeline: content=Timeline: content=
content=
Code
pz.container(ui.timeline([ui.TimelineItem("Ada commented", "Looks good to me!", time="Today", icon="message-circle", content=ui.facepile(["Ada", "Grace"]))]), width=340)

Timeline 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_press (index) Called with the index of a clicked entry.

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 Orders(pz.App):
def __init__(self):
self.opened = None
def open(self, index): # on_press: the index of the clicked entry
self.opened = index
def view(self):
return ui.timeline([
ui.TimelineItem("Order placed", time="09:12", icon="shopping-cart"),
ui.TimelineItem("Shipped", "On its way.", time="14:30", icon="truck",
tint="success" if self.opened == 1 else "accent"),
], on_press=self.open)
timeline(items, *, on_press=None, dense=False, theme=None)

Events in order down a line: a history, a changelog, the steps of a delivery. Each entry gets a dot joined to the next one.

Property Default Description
items required ui.TimelineItem objects, dicts with the same keys or plain titles.
dense False Small dots and less space.
theme None Theme to use instead of the current one (pyzed.theme.current()).

Events: on_press (events).

Full reference →

@dataclass
class TimelineItem(title, description=None, time=None, icon=None, tint='accent', content=None)

One entry of ui.timeline.

Property Default Description
title required Title.
description None Muted text under the title.
time None Text at the right of the title (a date, an hour).
icon None Icon inside the dot.
tint "accent" Color of the dot.
content None Any widget under the text.

Full reference →