The reason that strings are used over a callable is that (in a future update) key bindings may be loaded from a configuration file. The action strings are parsed and may not include expressions or arbitrary code. You could be forgiven for thinking that "color('red')" is Python code which Textual evaluates. When you press any of these three keys Textual will call the method action_color with the appropriate parameter.
In the on_load method we have bound the keys R, G, and B to the color action with a single parameter. If you run this app you can hit the keys R, G, or B to change the color of the background.
You can install Textual via pip ( pip install textual), or by checking out the repo and installing with poetry.įrom textual. Other techniques are borrowed from JS frameworks such as Vue and React. Textual has more in common with modern web development than it does with curses layout is done with CSS grid and (soon) the theme may be customized with CSS. Widgets (UI components) can independently update and communicate with each other via message passing. Textual uses Rich to render rich text, so anything that Rich can render may be used in Textual.Įvent handling in Textual is asynchronous (using async and await keywords). Textual currently runs on MacOS / Linux / Windows.
If you would like to contribute code via a PR, please raise a discussion first, to avoid disappointment.įollow for progress updates, or post in Discussions if you have any requests / suggestions. We will maintain the 0.1.0 branch for the near future but may not be able to accept API changes. We ( Textualize.io) are hard at work on the css branch. Textual is a TUI (Text User Interface) framework for Python inspired by modern web development.