ScrollableTextLayout Class

Inheritance diagram of ScrollableTextLayout

class ScrollableTextLayout(document, width, height, multiline=False, dpi=None, batch=None, group=None, wrap_lines=True)

Display text in a scrollable viewport.

This class does not display a scrollbar or handle scroll events; it merely clips the text that would be drawn in TextLayout to the bounds of the layout given by x, y, width and height; and offsets the text by a scroll offset.

Use view_x and view_y to scroll the text within the viewport.

Constructor:

__init__(document, width, height, multiline=False, dpi=None, batch=None, group=None, wrap_lines=True)

Methods:

begin_update() Indicate that a number of changes to the layout or document are about to occur.
delete() Remove this layout from its batch.
draw() Draw this text layout.
end_update() Perform pending layout changes since begin_update.
on_delete_text(start, end) Event handler for AbstractDocument.on_delete_text.
on_insert_text(start, text) Event handler for AbstractDocument.on_insert_text.
on_style_text(start, end, attributes) Event handler for AbstractDocument.on_style_text.

Attributes:

anchor_x
anchor_y
background_group A group with partial order.
content_valign Vertical alignment of content within larger layout box.
document
dpi Get DPI used by this layout.
foreground_decoration_group Rendering group for decorative elements (e.g., glyph underlines) in all text layouts.
foreground_group Rendering group for foreground elements (glyphs) in all text layouts.
height
multiline Set if multiline layout is enabled.
top_group Type: TextLayoutGroup
view_x Horizontal scroll offset.
view_y Vertical scroll offset.
width
x
y

Attributes

ScrollableTextLayout.anchor_x
ScrollableTextLayout.anchor_y
ScrollableTextLayout.height
ScrollableTextLayout.view_x

Horizontal scroll offset.

The initial value is 0, and the left edge of the text will touch the left side of the layout bounds. A positive value causes the text to “scroll” to the right. Values are automatically clipped into the range [0, content_width - width]

Type:int
ScrollableTextLayout.view_y

Vertical scroll offset.

The initial value is 0, and the top of the text will touch the top of the layout bounds (unless the content height is less than the layout height, in which case content_valign is used).

A negative value causes the text to “scroll” upwards. Values outside of the range [height - content_height, 0] are automatically clipped in range.

Type:int
ScrollableTextLayout.width
ScrollableTextLayout.x
ScrollableTextLayout.y

Inherited members

Methods

ScrollableTextLayout.begin_update()

Indicate that a number of changes to the layout or document are about to occur.

Changes to the layout or document between calls to begin_update and end_update do not trigger any costly relayout of text. Relayout of all changes is performed when end_update is called.

Note that between the begin_update and end_update calls, values such as content_width and content_height are undefined (i.e., they may or may not be updated to reflect the latest changes).

ScrollableTextLayout.delete()

Remove this layout from its batch.

ScrollableTextLayout.draw()

Draw this text layout.

Note that this method performs very badly if a batch was supplied to the constructor. If you add this layout to a batch, you should ideally use only the batch’s draw method.

ScrollableTextLayout.end_update()

Perform pending layout changes since begin_update.

See begin_update.

ScrollableTextLayout.on_delete_text(start, end)

Event handler for AbstractDocument.on_delete_text.

The event handler is bound by the text layout; there is no need for applications to interact with this method.

ScrollableTextLayout.on_insert_text(start, text)

Event handler for AbstractDocument.on_insert_text.

The event handler is bound by the text layout; there is no need for applications to interact with this method.

ScrollableTextLayout.on_style_text(start, end, attributes)

Event handler for AbstractDocument.on_style_text.

The event handler is bound by the text layout; there is no need for applications to interact with this method.

Attributes

ScrollableTextLayout.background_group = OrderedGroup(0)
ScrollableTextLayout.content_valign

Vertical alignment of content within larger layout box.

This property determines how content is positioned within the layout box when content_height is less than height. It is one of the enumerants:

top (default)
Content is aligned to the top of the layout box.
center
Content is centered vertically within the layout box.
bottom
Content is aligned to the bottom of the layout box.

This property has no effect when content_height is greater than height (in which case the content is aligned to the top) or when height is None (in which case there is no vertical layout box dimension).

Type:str
ScrollableTextLayout.document
ScrollableTextLayout.dpi

Get DPI used by this layout.

Read-only.

Type:float
ScrollableTextLayout.foreground_decoration_group = TextLayoutForegroundDecorationGroup(2)
ScrollableTextLayout.foreground_group = TextLayoutForegroundGroup(1)
ScrollableTextLayout.multiline

Set if multiline layout is enabled.

If multiline is False, newline and paragraph characters are ignored and text is not word-wrapped. If True, the text is word-wrapped only if the wrap_lines is True.

Type:bool
ScrollableTextLayout.top_group = <pyglet.text.layout.TextLayoutGroup object at 0x7f5fb3adcc10>

Table Of Contents

Previous topic

IncrementalTextLayout Class

Next topic

ScrollableTextLayoutGroup Class