Skip to content

Text

Examples#

See these.

Text #

Bases: Shape

Draws value with style at the given (x, y) point.

alignment #

alignment: Alignment = field(
    default_factory=lambda: TOP_LEFT
)

A point within a text rectangle to determine its position and rotation center.

data #

data: Any = skip_field()

Arbitrary data of any type.

ellipsis #

ellipsis: str | None = None

String used to ellipsize overflowing text.

key #

key: (
    str | int | float | bool | ValueKey | ScrollKey | None
) = None

max_lines #

max_lines: int | None = None

The maximum number of lines painted. Lines beyond this number are silently dropped. For example, if max_lines = 1, then only one line is rendered. If max_lines = None, but ellipsis != None, then lines after the first one that overflows the width constraints are dropped.

max_width #

max_width: Number | None = None

The maximum width of the painted text.

Defaults to None - infinity.

page #

page: Page | PageView | None

The page (of type Page or PageView) to which this control belongs to.

parent #

parent: BaseControl | None

The direct ancestor(parent) of this control.

It defaults to None and will only have a value when this control is mounted (added to the page tree).

The Page control (which is the root of the tree) is an exception - it always has parent=None.

rotate #

rotate: Number = 0

The rotation of this text in radians. Text is rotated around the point determined by alignment.

spans #

spans: list[TextSpan] | None = None

The list of TextSpan objects to build a rich text paragraph.

style #

style: TextStyle | None = None

A text style to draw text and spans with.

text_align #

text_align: TextAlign = START

Text horizontal align.

value #

value: str | None = None

The text to draw.

x #

x: Number

The x-axis coordinate of the text's alignment point.

y #

y: Number

The y-axis coordinate of the text's alignment point.

before_event #

before_event(e: ControlEvent)

before_update #

before_update()

This method is called every time when this control is being updated.

Note

Make sure not to call/request an update() here.

did_mount #

did_mount()

init #

init()

is_isolated #

is_isolated()

update #

update() -> None

will_unmount #

will_unmount()