When working with Textual, here are some notes:
-
Widgets have a lot of CPU overhead, since each one invokes callbacks during mount/compose and things have to be laid out, styled, etc. Therefore, prefer to use
Widget.render() -> Text
to return a text representation of large, static content. SaveWidget.compose()
for containers and layouts. -
Use egregious background colors to figure out the boundary of widget, like
background: green
. Since borders are so wide (one character/row) setting a border like you might do in HTML doesn’t work quite as well. -
Rich doesn’t have access to class styles or CSS styling provided at the Textual level. This causes a temptation to use lots of small widgets, but see #1. Instead, inspect the app stylesheet and resolve the style you want into a
Rich.Style
and pass intoRich.Text(..., style=style)
.