Text Layout Classes

class urwid.TextLayout
layout(text, width, align, wrap)

Return a layout structure for text.

Parameters:
  • text – string in current encoding or unicode string
  • width – number of screen columns available
  • align – align mode for text
  • wrap – wrap mode for text

Layout structure is a list of line layouts, one per output line. Line layouts are lists than may contain the following tuples:

  • (column width of text segment, start offset, end offset)
  • (number of space characters to insert, offset or None)
  • (column width of insert text, offset, “insert text”)

The offset in the last two tuples is used to determine the attribute used for the inserted spaces or text respectively. The attribute used will be the same as the attribute at that text offset. If the offset is None when inserting spaces then no attribute will be used.

supports_align_mode(align)

Return True if align is a supported align mode.

supports_wrap_mode(wrap)

Return True if wrap is a supported wrap mode.

class urwid.StandardTextLayout
align_layout(text, width, segs, wrap, align)

Convert the layout segs to an aligned layout.

calculate_text_segments(text, width, wrap)

Calculate the segments of text to display given width screen columns to display them.

text - unicode text or byte string to display width - number of available screen columns wrap - wrapping mode used

Returns a layout structure without alignment applied.

layout(text, width, align, wrap)

Return a layout structure for text.

pack(maxcol, layout)

Return a minimal maxcol value that would result in the same number of lines for layout. layout must be a layout structure returned by self.layout().

supports_align_mode(align)

Return True if align is ‘left’, ‘center’ or ‘right’.

supports_wrap_mode(wrap)

Return True if wrap is ‘any’, ‘space’ or ‘clip’.

Table of contents

Previous topic

Canvas Classes and Functions

Next topic

Command Map

This Page