Core API¶
The nuiitivet package exposes the core primitives, layout widgets, and state management utilities.
nuiitivet
¶
nuiitivet package.
Core functionality and configuration primitives are exposed here.
Column
¶
Column(children: Optional[Sequence[Widget]] = None, *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, gap: Union[int, ReadOnlyObservableProtocol] = 0, main_alignment: str = 'start', cross_alignment: str = 'start')
Bases: Widget
Layout children vertically.
Parameters - gap: pixels between children - cross_alignment: 'start'|'center'|'end' for cross-axis (horizontal) alignment - main_alignment: 'start'|'center'|'end'|'space-between'|'space-around'|'space-evenly' - padding: inner padding as int (all sides), (h, v), or (left, top, right, bottom) - overflow: 'visible'|'clip'|'scroll' - how to handle children that overflow the container - 'visible' (default): children may extend beyond container (Phase 1 behavior) - 'clip': children are clipped to container bounds - 'scroll': requires VerticalScrollable / HorizontalScrollable wrapper (Phase 3)
Initialize Column and configure layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
children
|
Optional[Sequence[Widget]]
|
List of child widgets to arrange vertically. |
None
|
width
|
SizingLike
|
Column width. |
None
|
height
|
SizingLike
|
Column height. |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Padding around the content. |
0
|
gap
|
Union[int, ReadOnlyObservableProtocol]
|
Space between children in pixels. |
0
|
main_alignment
|
str
|
Vertical alignment of children. 'start', 'center', 'end', 'space-between', 'space-around', 'space-evenly'. |
'start'
|
cross_alignment
|
str
|
Horizontal alignment of children. 'start', 'center', 'end', 'stretch'. |
'start'
|
Source code in src/nuiitivet/layout/column.py
builder
classmethod
¶
builder(items: ItemsLike, builder: BuilderFn, *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, gap: int = 0, main_alignment: str = 'start', cross_alignment: str = 'start') -> Column
Create a Column that materializes children from items via ForEach.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
ItemsLike
|
Source data collection. |
required |
builder
|
BuilderFn
|
Function to create a widget for each item. |
required |
width
|
SizingLike
|
Column width. |
None
|
height
|
SizingLike
|
Column height. |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Padding around the content. |
0
|
gap
|
int
|
Space between children. |
0
|
main_alignment
|
str
|
Vertical alignment of children. |
'start'
|
cross_alignment
|
str
|
Horizontal alignment of children. |
'start'
|
Source code in src/nuiitivet/layout/column.py
Row
¶
Row(children: Optional[List[Widget]] = None, *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, gap: Union[int, ReadOnlyObservableProtocol] = 0, main_alignment: str = 'start', cross_alignment: str = 'start')
Bases: Widget
Layout children horizontally.
Parameters - gap: pixels between children - cross_alignment: 'start'|'center'|'end' for cross-axis (vertical) alignment - main_alignment: 'start'|'center'|'end'|'space-between'|'space-around'|'space-evenly' - padding: inner padding as int (all sides), (h, v), or (left, top, right, bottom)
Initialize Row and configure layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
children
|
Optional[List[Widget]]
|
List of child widgets to arrange horizontally. |
None
|
width
|
SizingLike
|
Row width. Defaults to None (shrinkwrap). |
None
|
height
|
SizingLike
|
Row height. Defaults to None (shrinkwrap). |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Padding around the content. |
0
|
gap
|
Union[int, ReadOnlyObservableProtocol]
|
Space between children in pixels. |
0
|
main_alignment
|
str
|
Horizontal alignment of children. 'start', 'center', 'end', 'space-between', 'space-around', 'space-evenly'. |
'start'
|
cross_alignment
|
str
|
Vertical alignment of children. 'start', 'center', 'end', 'stretch'. |
'start'
|
Source code in src/nuiitivet/layout/row.py
builder
classmethod
¶
builder(items: ItemsLike, builder: BuilderFn, *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, gap: int = 0, main_alignment: str = 'start', cross_alignment: str = 'start') -> Row
Create a Row that materializes children from items via ForEach.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
ItemsLike
|
Source data collection. |
required |
builder
|
BuilderFn
|
Function to create a widget for each item. |
required |
width
|
SizingLike
|
Row width. |
None
|
height
|
SizingLike
|
Row height. |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Padding around the content. |
0
|
gap
|
int
|
Space between children. |
0
|
main_alignment
|
str
|
Horizontal alignment of children. |
'start'
|
cross_alignment
|
str
|
Vertical alignment of children. |
'start'
|
Source code in src/nuiitivet/layout/row.py
Stack
¶
Stack(children: Sequence[Widget], *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, alignment: AlignmentLike = 'top-left')
Bases: Widget
Layout children on top of each other.
Parameters - children: List of widgets to stack. - alignment: How to align children within the stack.
Initialize the Stack layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
children
|
Sequence[Widget]
|
List of widgets to stack on top of each other. |
required |
width
|
SizingLike
|
Stack width. |
None
|
height
|
SizingLike
|
Stack height. |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Padding around the content. |
0
|
alignment
|
AlignmentLike
|
Default alignment for children. (horizontal, vertical) tuple or string like "top-left", "center". |
'top-left'
|
Source code in src/nuiitivet/layout/stack.py
builder
classmethod
¶
builder(items: ItemsLike, builder: BuilderFn, *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, alignment: AlignmentLike = 'center') -> 'Stack'
Create a Stack that materializes children from items via ForEach.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
ItemsLike
|
Source data collection. |
required |
builder
|
BuilderFn
|
Function to create a widget for each item. |
required |
width
|
SizingLike
|
Stack width. |
None
|
height
|
SizingLike
|
Stack height. |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Padding around the content. |
0
|
alignment
|
AlignmentLike
|
Default alignment for children. |
'center'
|
Source code in src/nuiitivet/layout/stack.py
Container
¶
Container(child: Optional[Widget] = None, *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, alignment: Union[str, Tuple[str, str]] = 'start')
Bases: Widget
Lightweight layout-only Container.
This Container is a minimal single-child layout box. It intentionally does not perform background/shadow/border drawing or clipping.
Initialize the Container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
child
|
Optional[Widget]
|
The child widget to be placed inside the container. |
None
|
width
|
SizingLike
|
The preferred width of the container. Defaults to None (shrinkwrap). |
None
|
height
|
SizingLike
|
The preferred height of the container. Defaults to None (shrinkwrap). |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Padding to apply around the child. Can be a single integer, a 2-tuple (horizontal, vertical), or a 4-tuple (left, top, right, bottom). |
0
|
alignment
|
Union[str, Tuple[str, str]]
|
How to align the child within the container. Defaults to "start". Can be a string (e.g., "center") or a tuple (horizontal, vertical). |
'start'
|
Source code in src/nuiitivet/layout/container.py
Flow
¶
Flow(children: Optional[Sequence[Widget]] = None, *, main_gap: int = 0, cross_gap: int = 0, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, main_alignment: str = 'start', run_alignment: str = 'start', cross_alignment: str = 'start', width: SizingLike = None, height: SizingLike = None)
Bases: Widget
Layout children in rows that wrap.
Arranges children in a horizontal run, wrapping to a new line when the line runs out of space.
Source code in src/nuiitivet/layout/flow.py
builder
classmethod
¶
builder(items: ItemsLike, builder: BuilderFn, *, main_gap: int = 0, cross_gap: int = 0, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, main_alignment: str = 'start', run_alignment: str = 'start', cross_alignment: str = 'start', width: SizingLike = None, height: SizingLike = None) -> 'Flow'
Create a Flow that materializes children from items via ForEach.
Source code in src/nuiitivet/layout/flow.py
UniformFlow
¶
UniformFlow(children: Optional[Sequence[Widget]] = None, *, columns: Optional[int] = None, max_column_width: Optional[int] = None, aspect_ratio: Optional[float] = None, main_gap: int = 0, cross_gap: int = 0, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, main_alignment: str = 'start', run_alignment: str = 'start', item_alignment: AlignValue = 'stretch', width: SizingLike = None, height: SizingLike = None)
Bases: Widget
Layout children in a uniform grid.
This layout arranges children into columns with equal width.
Source code in src/nuiitivet/layout/uniform_flow.py
builder
classmethod
¶
builder(items: ItemsLike, builder: BuilderFn, *, columns: Optional[int] = None, max_column_width: Optional[int] = None, aspect_ratio: Optional[float] = None, main_gap: int = 0, cross_gap: int = 0, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, main_alignment: str = 'start', run_alignment: str = 'start', item_alignment: AlignValue = 'stretch', width: SizingLike = None, height: SizingLike = None) -> 'UniformFlow'
Create a UniformFlow that materializes children from items via ForEach.
Source code in src/nuiitivet/layout/uniform_flow.py
Grid
¶
Grid(children: Optional[Sequence[Widget]], rows: Optional[Sequence[SizingLike]], columns: Optional[Sequence[SizingLike]], *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, row_gap: int = 0, column_gap: int = 0)
Bases: Widget
Two-dimensional layout container with explicit tracks.
Initialize the Grid layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
children
|
Optional[Sequence[Widget]]
|
List of GridItems to display. |
required |
rows
|
Optional[Sequence[SizingLike]]
|
List of row sizes (e.g. [100, "1fr", "auto"]). |
required |
columns
|
Optional[Sequence[SizingLike]]
|
List of column sizes. |
required |
width
|
SizingLike
|
Grid container width. |
None
|
height
|
SizingLike
|
Grid container height. |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Padding around the grid content. |
0
|
row_gap
|
int
|
Vertical gap between rows. |
0
|
column_gap
|
int
|
Horizontal gap between columns. |
0
|
Source code in src/nuiitivet/layout/grid.py
named_areas
classmethod
¶
named_areas(children: Sequence[Widget], areas: Sequence[Sequence[str]], *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, row_gap: int = 0, column_gap: int = 0, rows: Optional[Sequence[SizingLike]] = None, columns: Optional[Sequence[SizingLike]] = None) -> Grid
Create a Grid using named template areas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
children
|
Sequence[Widget]
|
List of child widgets (usually GridItem.named_area). |
required |
areas
|
Sequence[Sequence[str]]
|
2D list of area names (e.g. [["header", "header"], ["sidebar", "content"]]). |
required |
width
|
SizingLike
|
Grid width. |
None
|
height
|
SizingLike
|
Grid height. |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Grid padding. |
0
|
row_gap
|
int
|
Gap between rows. |
0
|
column_gap
|
int
|
Gap between columns. |
0
|
rows
|
Optional[Sequence[SizingLike]]
|
Explicit row sizing overrides. |
None
|
columns
|
Optional[Sequence[SizingLike]]
|
Explicit column sizing overrides. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Grid |
Grid
|
A configured Grid instance. |
Source code in src/nuiitivet/layout/grid.py
GridItem
¶
GridItem(child: Widget, row: Optional[GridIndex] = None, column: Optional[GridIndex] = None, *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, alignment: Union[str, Tuple[str, str]] = 'start')
Bases: Container
Annotate a child with explicit grid placement data.
Initialize the GridItem wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
child
|
Widget
|
The widget to place in the grid. |
required |
row
|
Optional[GridIndex]
|
Row index or (start, end) tuple. 0-based. |
None
|
column
|
Optional[GridIndex]
|
Column index or (start, end) tuple. 0-based. |
None
|
width
|
SizingLike
|
Override width. |
None
|
height
|
SizingLike
|
Override height. |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Padding around the child within the grid cell. |
0
|
alignment
|
Union[str, Tuple[str, str]]
|
Alignment within the grid cell. Defaults to "start". |
'start'
|
Source code in src/nuiitivet/layout/grid.py
named_area
classmethod
¶
named_area(child: Widget, name: str, *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, alignment: Union[str, Tuple[str, str]] = 'start') -> GridItem
Create a GridItem placed in a named template area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
child
|
Widget
|
The child widget to place. |
required |
name
|
str
|
The area name matching a name in Grid.named_areas(). |
required |
width
|
SizingLike
|
Override width. |
None
|
height
|
SizingLike
|
Override height. |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Padding around the child within the grid cell. |
0
|
alignment
|
Union[str, Tuple[str, str]]
|
Alignment within the grid cell. Defaults to "start". |
'start'
|
Returns:
| Name | Type | Description |
|---|---|---|
GridItem |
GridItem
|
The wrapped widget with area information. |
Source code in src/nuiitivet/layout/grid.py
Spacer
¶
Bases: Widget
Invisible widget that reserves space.
This single Spacer supports both fixed-size and flexible behavior.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
SizingLike
|
preferred width (int, "auto", "{f}%", or Sizing) |
0
|
height
|
SizingLike
|
preferred height (same accepted formats as width) |
0
|
Initialize a Spacer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
SizingLike
|
Preferred width. Use Sizing.flex() or 0 for flexible space. |
0
|
height
|
SizingLike
|
Preferred height. Use Sizing.flex() or 0 for flexible space. |
0
|
Source code in src/nuiitivet/layout/spacer.py
preferred_size
¶
preferred_size(max_width: Optional[int] = None, max_height: Optional[int] = None) -> Tuple[int, int]
Return preferred size based on Sizings.
- fixed: return the fixed value
- auto/flex: return 0 (minimum size, parent will allocate)
Source code in src/nuiitivet/layout/spacer.py
CrossAligned
¶
CrossAligned(child: Optional[Widget], alignment: str)
Bases: Widget
Layout wrapper that overrides cross-axis alignment in Row/Column.
This sets cross_align metadata on the wrapper. Row/Column may read
this to override their cross_alignment for this child only.
Initialize the CrossAligned wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
child
|
Optional[Widget]
|
The child widget to wrap. |
required |
alignment
|
str
|
The cross-axis alignment to apply to this child. Common values: "start", "center", "end", "stretch". |
required |
Source code in src/nuiitivet/layout/cross_aligned.py
Deck
¶
Deck(children: Optional[Sequence[Widget]] = None, index: Union[int, _ObservableValue[int]] = 0, *, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0)
Bases: Widget
Display only one child at a time.
All children remain mounted (state preserved), but only the selected child is visible and rendered.
Usage
Deck(children=[HomeTab(), SearchTab(), ProfileTab()], index=0)
For type-safe index, use IntEnum: class Section(IntEnum): HOME = 0 SEARCH = 1 Deck(children=[...], index=Section.HOME)
For animated tabs with gesture support, see DeckController.
Initialize the Deck layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
children
|
Optional[Sequence[Widget]]
|
A list of child widgets. All are mounted, but only one is visible. |
None
|
index
|
Union[int, _ObservableValue[int]]
|
The index of the child to display. Can be an integer or an Observable[int]. Defaults to 0. |
0
|
width
|
SizingLike
|
The preferred width of the container. Defaults to None. |
None
|
height
|
SizingLike
|
The preferred height of the container. Defaults to None. |
None
|
padding
|
Union[int, Tuple[int, int], Tuple[int, int, int, int]]
|
Padding to apply around the visible child. Defaults to 0. |
0
|
Source code in src/nuiitivet/layout/deck.py
set_index
¶
Set the selected child index (for non-Observable usage).
Source code in src/nuiitivet/layout/deck.py
layout
¶
Layout all children (to preserve state), position selected child.
Source code in src/nuiitivet/layout/deck.py
paint
¶
Paint only the selected child.
Source code in src/nuiitivet/layout/deck.py
hit_test
¶
Only allow hit testing on the selected child.
Source code in src/nuiitivet/layout/deck.py
Collapsible
¶
Collapsible(child: Optional[Widget] = None, *, opened: Union[bool, ReadOnlyObservableProtocol[bool]] = True, motion: Motion = _DEFAULT_MOTION, motion_out: Optional[Motion] = None, axis: Axis = 'both', alignment: Union[str, Tuple[str, str]] = 'top_left')
Bases: Widget
Single-child widget that animates its layout size open and closed.
The child is always mounted and laid out at its own natural size; the allocated rectangle reported to the parent is interpolated per axis. The animated rectangle is clipped internally, so the child never overflows its allocated bounds.
Initialize a Collapsible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
child
|
Optional[Widget]
|
The |
None
|
opened
|
Union[bool, ReadOnlyObservableProtocol[bool]]
|
|
True
|
motion
|
Motion
|
Base motion used for both open (enter) and close (exit). |
_DEFAULT_MOTION
|
motion_out
|
Optional[Motion]
|
Optional motion that overrides only the close (exit)
direction. When omitted, |
None
|
axis
|
Axis
|
Which axis/axes to animate ( |
'both'
|
alignment
|
Union[str, Tuple[str, str]]
|
Alignment of the child within the animated rectangle. |
'top_left'
|
Source code in src/nuiitivet/layout/collapsible.py
VerticalScrollable
¶
VerticalScrollable(child: Widget, *, controller: Optional[ScrollController] = None, scrollbar_visible: ScrollbarVisibleLike = True, width: SizingLike = None, height: SizingLike = None, scrollbar_behavior: Optional[ScrollbarBehavior] = None, scrollbar_style: Optional[ScrollbarStyle] = None, style: Optional[ScrollableStyle] = None)
Bases: _ScrollableBase
Scrolls its child along the vertical axis.
Source code in src/nuiitivet/layout/scrollable.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
HorizontalScrollable
¶
HorizontalScrollable(child: Widget, *, controller: Optional[ScrollController] = None, scrollbar_visible: ScrollbarVisibleLike = True, width: SizingLike = None, height: SizingLike = None, scrollbar_behavior: Optional[ScrollbarBehavior] = None, scrollbar_style: Optional[ScrollbarStyle] = None, style: Optional[ScrollableStyle] = None)
Bases: _ScrollableBase
Scrolls its child along the horizontal axis.
Source code in src/nuiitivet/layout/scrollable.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
Widget
¶
Widget(*, width: Union[SizingLike, ReadOnlyObservableProtocol] = None, height: Union[SizingLike, ReadOnlyObservableProtocol] = None, padding: Union[PaddingLike, ReadOnlyObservableProtocol] = None, max_children: Optional[int] = None, overflow_policy: str = 'none')
Bases: BindingHostMixin, LifecycleHostMixin, InputHubMixin, ChildContainerMixin, WidgetKernel
Leaf-friendly widget base composed from mixins.
This class intentionally does not participate in build/recomposition.
Widgets that need build()/rebuild()/scope() must inherit
ComposableWidget.
Source code in src/nuiitivet/widgeting/widget.py
mark_needs_layout
¶
Mark this widget as needing layout recalculation.
Source code in src/nuiitivet/widgeting/widget.py
find_ancestor
¶
Find the nearest ancestor of the specified type.
Traverses up the widget tree looking for an ancestor that matches the given type. This is used to implement context lookup patterns like Navigator.of(context).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
widget_type
|
Type[T]
|
The type of widget to find. |
required |
Returns:
| Type | Description |
|---|---|
Optional[T]
|
The nearest ancestor of the specified type, or None if not found. |
Example
navigator = self.find_ancestor(Navigator) if navigator: navigator.push(...)
Source code in src/nuiitivet/widgeting/widget.py
modifier
¶
modifier(modifier: Union[Modifier, ModifierElement]) -> Widget
Apply a modifier to this widget, returning the wrapped result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modifier
|
Union[Modifier, ModifierElement]
|
The modifier (or modifier element) to apply. |
required |
Returns:
| Type | Description |
|---|---|
Widget
|
The wrapped widget (e.g. ModifierBox) or the widget itself if modified in-place. |
Source code in src/nuiitivet/widgeting/widget.py
ComposableWidget
¶
Bases: BuilderHostMixin, Widget
Widget base that participates in build/recomposition.
Composition widgets can override build() and use scope() /
render_scope() for fine-grained recomposition.
Source code in src/nuiitivet/widgeting/widget_builder.py
Navigator
¶
Navigator(screen: Route | Widget | None = None, *, layer_composer: NavigationLayerComposer | None = None)
Bases: ComposableWidget
A minimal navigation stack.
Initialization forms
Navigator(screen): start with a single screen (RouteorWidget).Navigator.routes([...]): pre-populated stack (e.g. deep linking).Navigator.intents(initial_route=..., routes={...}): Intent-based routing.
Features
- push/pop
- root()/set_root()
- of(context)
- optional fade-in on push
Initialize a Navigator with a single initial screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen
|
Route | Widget | None
|
The initial screen as a |
None
|
layer_composer
|
NavigationLayerComposer | None
|
Optional custom layer composer. |
None
|
Source code in src/nuiitivet/navigation/navigator.py
routes
classmethod
¶
routes(screens: Sequence[Route | Widget], *, layer_composer: NavigationLayerComposer | None = None) -> Navigator
Create a Navigator with a pre-populated stack.
Use this when the navigator should start with multiple screens already on the stack (e.g. deep linking, state restoration).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screens
|
Sequence[Route | Widget]
|
Sequence of |
required |
layer_composer
|
NavigationLayerComposer | None
|
Optional custom layer composer. |
None
|
Source code in src/nuiitivet/navigation/navigator.py
intents
classmethod
¶
intents(*, initial_route: Any, routes: Mapping[type[Any], Callable[[Any], Route | Widget]], layer_composer: NavigationLayerComposer | None = None) -> Navigator
Create a Navigator configured for Intent-based routing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_route
|
Any
|
The initial Intent instance used to resolve the first route. |
required |
routes
|
Mapping[type[Any], Callable[[Any], Route | Widget]]
|
Mapping of Intent types to route builder functions. Each
builder returns a |
required |
layer_composer
|
NavigationLayerComposer | None
|
Optional custom layer composer. |
None
|
Source code in src/nuiitivet/navigation/navigator.py
request_back
async
¶
Request a single back action.
This API is designed for user back inputs (Esc/back button). If a pop transition is already running, the request is queued and the current transition is completed immediately.
Queue consumption policy: - Intermediate queued pops are performed without animation. - The last queued pop (if any) uses the normal pop behavior.
Source code in src/nuiitivet/navigation/navigator.py
Observable
¶
Bases: _ObservableValue[T]
Descriptor for a per-instance observable that can also be used standalone.
Source code in src/nuiitivet/observable/value.py
OSChrome
dataclass
¶
OS-managed window decoration.
Maps variant directly to pyglet.window.Window.WINDOW_STYLE_*.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variant
|
OSChromeVariant
|
Window style. One of: "default", "dialog", "tool", "borderless", "transparent". |
'default'
|
CustomChrome
dataclass
¶
CustomChrome(header: 'Widget', corner_radius: float = 0.0, border: Optional[Border] = None)
Custom (app-drawn) window decoration.
Always uses a borderless OS window (no OS title bar).
Wraps header in :class:~nuiitivet.runtime.title_bar.WindowDragArea
so the user can drag the window by the header.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
header
|
'Widget'
|
Widget rendered as the window's title-bar area. |
required |
corner_radius
|
float
|
Corner radius in logical pixels applied by the render layer. Content is clipped to a rounded rectangle; pixels outside the rounded corners are cleared to transparent. Note that true desktop-transparency in the corners requires platform-level window compositing support. |
0.0
|
border
|
Optional[Border]
|
Optional border drawn around the window edge inside the rounded-corner boundary. |
None
|
Border
dataclass
¶
Border specification for CustomChrome.
Attributes:
| Name | Type | Description |
|---|---|---|
color |
'ColorSpec'
|
Border color (any ColorSpec accepted by the theme system). |
width |
float
|
Border width in logical pixels. |
batch
¶
Context manager for batching Observable updates.
set_default_font_family
¶
Set the system-wide default font family.
This font will be prioritized over locale-based defaults. Pass None to reset to automatic locale detection.
Source code in src/nuiitivet/rendering/skia/font.py
register_font
¶
Register a font file under a custom family name.
Call this at application startup before any rendering. Once registered,
the family name can be used wherever a font_family is accepted (e.g.
TextStyle(font_family=...), Icon(..., font_family=...)).
Fonts are loaded lazily on first use and cached for subsequent calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Absolute or relative path to a |
required |
family_name
|
str
|
The name to associate with this font. |
required |