pygfx.objects.TextBlock

class pygfx.objects.TextBlock(index, dirty_blocks)

Bases: object

The TextBlock represents one block or paragraph of text.

Users can obtain instances of this class from the MultiText object.

Text blocks are positioned using an entry in text_object.geometry.positions. The Text object uses text blocks internally to do efficient re-layout when text is updated. With the MultiText object the text blocks are positioned by the user or external code.

property index

The index in the geometry.positions buffer.

set_text(text: str)

Set the text for this TextBlock (as a string).

This is called from Text.set_text(), but can also be called directly. Note that in contrast to Text.set_text(), setting the text on a TextBlock does not result in a re-layout (i.e. the bounding box is not updated until after the next draw).

set_markdown(text: str)

Set the markdown for this TextBlock (as a string).

This is called from Text.set_markdown(), but can also be called directly. Note that in contrast to Text.set_markdown(), setting the text on a TextBlock does not result in a re-layout (i.e. the bounding box is not updated until after the next draw).

Examples

Text multiple grid

Text multiple grid

Text multiple labels

Text multiple labels