Page
Page holds widgets, their layout and their actions, and goes on the dashboard with dachshund.include(). See the Pages guide.
import dachshund
from dachshund import Page
from dachshund.widgets import Number, TimeSeriesChart
page = Page("overview", title="Overview")
with page.row():
with page.column(span=4):
page.add(Number("errors"))
page.add(Number("users"))
page.add(TimeSeriesChart("latency"))
dachshund.include(page)
dachshund.layout.Page
Page(name, *, title=None, public=False)
A page of the dashboard, with its widgets, layout and actions.
Register on a page, then put it on the dashboard with dachshund.include().
See the Pages guide.
Example
page = Page("overview", title="Overview")
with page.row():
page.add(Text("summary"))
with page.row():
with page.column(span=4):
page.add(Number("errors"))
page.add(Number("users"))
page.add(TimeSeriesChart("latency"))
@page.action("flush", label="Flush cache")
def flush(ctx): ...
dachshund.include(page)
Options
name(str) - The page's URL,/<name>. Can't contain/or start with_. Required.title(str) - Shown in the navigation. Defaults toname, underscores as spaces.public(bool) - Shown without the dashboard'sauthorize, see Authentication. Its tabs follow it. Defaults toFalse.
Layout
A page is rows on a 12-column grid, laid out with with blocks. Widgets
live in rows: add() puts a widget in the innermost open block,
- in a
column(), stacked under the widgets already there - in a
row(), as a column of its own
and raises outside of both. A full-width widget is a row with one widget.
A column's span is its width out of 12. Columns without one share what's
left evenly.
Tabs
A page holds either widgets or tab()s. Its tabs are listed in a sidebar,
and visiting the page shows the first one.
Source code in dachshund/layout.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
name
instance-attribute
name = name
title
instance-attribute
title = title
public
instance-attribute
public = public
parent
instance-attribute
parent = None
rows
instance-attribute
rows = []
widgets
instance-attribute
widgets = {}
actions
instance-attribute
actions = {}
tabs
instance-attribute
tabs = {}
included
instance-attribute
included = False
path
property
path
Where the page lives, "parent/tab" for a tab.
row
row()
Open a row: widgets added until the block ends sit side by side.
Example
with page.row():
page.add(Number("errors"))
page.add(TimeSeriesChart("latency"))
Source code in dachshund/layout.py
261 262 263 264 265 266 267 268 269 270 271 272 | |
column
column(*, span=None)
Open a column inside a row: widgets added until the block ends stack.
Options
span(int) - Columns wide, out of 12. Defaults to an even share of what the row's other columns leave.
Source code in dachshund/layout.py
274 275 276 277 278 279 280 281 282 | |
tab
tab(name, *, title=None)
Open a tab: rows and widgets added until the block ends go on it.
A tab is a page nested under this one, at /<page>/<name>.
Options
name(str) - The tab's URL. Required.title(str) - Shown in the sidebar. Defaults toname, underscores as spaces.
Source code in dachshund/layout.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
add
add(widget)
Put a widget in the open row or column, see Layout.
Source code in dachshund/layout.py
299 300 301 | |
action
action(name, *, label=None, confirm=False, public=False)
Register an action, see Dashboard.action.
Source code in dachshund/layout.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
every
every()
This page and its tabs, recursively.
Source code in dachshund/layout.py
342 343 344 | |
dachshund.layout.Row
dataclass
Row(columns=list())
Columns side by side on a 12-column grid.
columns
class-attribute
instance-attribute
columns = field(default_factory=list)
spans
spans()
Each column's width out of 12. Unsized columns share what's left evenly.
Source code in dachshund/layout.py
33 34 35 36 37 38 39 40 41 42 43 44 | |
check
check()
Source code in dachshund/layout.py
46 47 48 49 50 51 52 | |
dachshund.layout.Column
dataclass
Column(names=list(), span=None)
Widgets stacked top to bottom in one column of a row.
Options
names(list[str]) - The widgets, top to bottom.span(int) - Columns wide, out of 12. Defaults toNone, an even share of what the row's other columns leave.
names
class-attribute
instance-attribute
names = field(default_factory=list)
span
class-attribute
instance-attribute
span = None