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)
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: Space around 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
¶
Return the active type-scale token (defaults to Body Medium).
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
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 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 | |
paint
¶
Paint text with padding, multi-line layout and overflow support.
Source code in src/nuiitivet/widgets/text.py
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 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
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.