Primitives¶
Low-level widget implementations (Foundation layer).
widgets
¶
Flat widget API for nuiitivet.
Expose the flat widget implementations under nuiitivet.widgets.
TextBase
¶
TextBase(label: Union[str, ReadOnlyObservableProtocol[Any]], style: Optional[TextStyleProtocol] = None, width: SizingLike = None, height: SizingLike = None, padding: Union[int, Tuple[int, int], Tuple[int, int, int, int]] = 0, *, type_scale: Optional[TypeScaleToken] = None, alignment: Literal['start', 'center', 'end'] = 'start', max_lines: Optional[int] = None, overflow: Literal['visible', 'clip', 'ellipsis'] = 'visible', truncation: Literal['tail', 'head', 'middle'] = 'tail', soft_wrap: bool = True, key: Optional[str] = None)
Bases: Widget
Display text with optional Observable binding.
Parameters:
- label: Text string or Observable
- style: Visual style (color, font_family) — not typography or alignment
- type_scale: MD3 type-scale token supplying typography (font size, line
height, weight, tracking). Defaults to Body Medium.
- alignment: Horizontal text alignment within the box ("start",
"center", "end").
- width: Explicit width sizing
- height: Explicit height sizing
- padding: Insets from the allocated rect to the text
- max_lines: Maximum number of lines (None = unbounded). Hard line
breaks (\n) and soft wrapping both count toward this limit.
- overflow: What to do when text exceeds the layout box: "visible"
(draw beyond bounds), "clip" (cut at the edge), or "ellipsis"
(truncate the last visible line with …).
- truncation: Where the ellipsis is placed — "tail", "head" or
"middle". Only meaningful when overflow="ellipsis".
- soft_wrap: Whether text wraps at soft line breaks when the width is
bounded. Hard breaks (\n) always break regardless of this flag.
Source code in src/nuiitivet/widgets/text.py
type_scale
property
¶
type_scale: TypeScaleToken
Return the active type-scale token (defaults to Body Medium).
editable_parameters
classmethod
¶
preferred_size
¶
preferred_size(max_width: Optional[int] = None, max_height: Optional[int] = None) -> tuple[int, int]
Return the preferred (width, height) for this Text including padding (M3準拠).
Use explicit sizing if provided, otherwise measure text content.
Source code in src/nuiitivet/widgets/text.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
paint
¶
Paint text with padding, multi-line layout and overflow support.
Source code in src/nuiitivet/widgets/text.py
IconBase
¶
IconBase(size: SizingLike = 24, padding: Tuple[int, int, int, int] | Tuple[int, int] | int = 0, **kwargs)
Bases: Widget
Base class for icon widgets.
Provides utilities for rendering text blobs centered in the widget area.
Source code in src/nuiitivet/widgets/icon.py
draw_blob
¶
Draw a text blob centered in the content area.