2.1.1.3.1. pyfx.view.common.selectable_text.SelectableText

class SelectableText(markup, align: Literal['left', 'center', 'right'] | Align = Align.LEFT, wrap: Literal['space', 'any', 'clip', 'ellipsis'] | WrapMode = WrapMode.SPACE, layout: text_layout.TextLayout | None = None)

A text widgets can be focused on.

The widget is used in any urwid.ListBox to make each text section being selectable, i.e. being focused on.

Methods

__init__(markup[, align, wrap, layout])

param markup:

content of text widget, one of:

get_line_translation(maxcol[, ta])

Return layout structure used to map self.text to a canvas.

get_text()

returns:

(text, display attributes)

keypress(size, key)

keypress() is required for any selectable widgets.

pack([size, focus])

Return the number of screen columns and rows required for this Text widget to be displayed without wrapping or clipping, as a single element tuple.

render(size[, focus])

Render contents with wrapping and alignment.

rows(size[, focus])

Return the number of rows the rendered text requires.

selectable()

returns:

True if this is a widget that is designed to take the

set_align_mode(mode)

Set text alignment mode.

set_layout(align, wrap[, layout])

Set the text layout object, alignment and wrapping modes at the same time.

set_text(markup)

Set content of text widget.

set_wrap_mode(mode)

Set text wrapping mode.

sizing()

returns:

A frozenset including one or more of 'box', 'flow' and

Attributes

align

attrib

Read-only property returning the run-length encoded display attributes of this widget

base_widget

Read-only property that steps through decoration widgets and returns the one at the base.

focus

Read-only property returning the child widget in focus for container widgets.

focus_position

Property for reading and setting the focus position for container widgets.

layout

text

Read-only property returning the complete bytes/unicode content of this widget

wrap

keypress(size, key)

keypress() is required for any selectable widgets.

selectable()
Returns:

True if this is a widget that is designed to take the focus, i.e. it contains something the user might want to interact with, False otherwise,

This default implementation returns _selectable. Subclasses may leave these is if the are not selectable, or if they are always selectable they may set the _selectable class variable to True.

If this method returns True then the keypress() method must be implemented.

Returning False does not guarantee that this widget will never be in focus, only that this widget will usually be skipped over when changing focus. It is still possible for non selectable widgets to have the focus (typically when there are no other selectable widgets visible).