Textual —Text Based UI’s in Python

Robby Boney
Short Bits
Published in
3 min readSep 7, 2021

--

“Textual is a TUI (Text User Interface) framework for Python inspired by modern web development. Currently a work in progress, but usable by brave souls who don’t mind some API instability between updates.”

~Textual Github Page

This project is really interesting and possibly looks like it could be quite valuable for terminal based apps such as monitoring apps, vim/emacs-like text editors, complex interactive CLIs or possibly even dashboards.

A Simple App

from textual.app import App


class Beeper(App):
def on_key(self):
self.console.bell()


Beeper.run()

Layouts with Widgets

Layouts in any app framework is a vital component to compose sensible UIs and Textual makes this quite straight forward with App.view.dock() function.

from textual.app import App
from textual.widgets import Placeholder


class SimpleApp(App):

async def on_mount(self) -> None:
await self.view.dock(Placeholder(), edge="left", size=40)
await self.view.dock(Placeholder(), Placeholder(), edge="top")


SimpleApp.run(log="textual.log")

--

--

Robby Boney
Short Bits

Director of Product Development @ Interject Data Systems. I write Software for Science, Data & Enterprise…https://robbyboney.notion.site/