Skip to content

Screen

Screen

Bases: Widget

A widget for the root of the app.

find_widget(widget)

Get the screen region of a Widget.

Parameters:

Name Type Description Default
widget Widget

A Widget within the composition.

required

Returns:

Name Type Description
Region MapGeometry

Region relative to screen.

Raises:

Type Description
NoWidget

If the widget could not be found in this screen.

focus_chain() property

Get widgets that may receive focus, in focus order.

Returns:

Type Description
list[Widget]

list[Widget]: List of Widgets in focus order.

focus_next()

Focus the next widget.

Returns:

Type Description
Widget | None

Widget | None: Newly focused widget, or None for no focus.

focus_previous()

Focus the previous widget.

Returns:

Type Description
Widget | None

Widget | None: Newly focused widget, or None for no focus.

get_offset(widget)

Get the absolute offset of a given Widget.

Parameters:

Name Type Description Default
widget Widget

A widget

required

Returns:

Name Type Description
Offset Offset

The widget's offset relative to the top left of the terminal.

get_style_at(x, y)

Get the style under a given coordinate.

Parameters:

Name Type Description Default
x int

X Coordinate.

required
y int

Y Coordinate.

required

Returns:

Name Type Description
Style Style

Rich Style object

get_widget_at(x, y)

Get the widget at a given coordinate.

Parameters:

Name Type Description Default
x int

X Coordinate.

required
y int

Y Coordinate.

required

Returns:

Type Description
tuple[Widget, Region]

tuple[Widget, Region]: Widget and screen region.

get_widgets_at(x, y)

Get all widgets under a given coordinate.

Parameters:

Name Type Description Default
x int

X coordinate.

required
y int

Y coordinate.

required

Returns:

Type Description
Iterable[tuple[Widget, Region]]

Iterable[tuple[Widget, Region]]: Sequence of (WIDGET, REGION) tuples.

is_current() property

Check if this screen is current (i.e. visible to user).

set_focus(widget, scroll_visible=True)

Focus (or un-focus) a widget. A focused widget will receive key events first.

Parameters:

Name Type Description Default
widget Widget | None

Widget to focus, or None to un-focus.

required
scroll_visible bool

Scroll widget in to view.

True

update_timer() property

Timer used to perform updates.

visible_widgets() property

Get a list of visible widgets.

widgets() property

Get all widgets.