textual README

The project's README from github.com/Textualize/textual. As one markdown file: README.md.

Discord Supported Python Versions PyPI version OS support

textual-splash

Textual

clock

Build cross-platform user interfaces with a simple Python API. Run your apps in the terminal or a web browser.

Textual's API combines modern Python with the best of developments from the web world, for a lean app development experience. De-coupled components and an advanced testing framework ensure you can maintain your app for the long-term.

Want some more examples? See the examples directory.

"""
An App to show the current time.
"""

from datetime import datetime

from textual.app import App, ComposeResult
from textual.widgets import Digits


class ClockApp(App):
    CSS = """
    Screen { align: center middle; }
    Digits { width: auto; }
    """

    def compose(self) -> ComposeResult:
        yield Digits("")

    def on_ready(self) -> None:
        self.update_clock()
        self.set_interval(1, self.update_clock)

    def update_clock(self) -> None:
        clock = datetime.now().time()
        self.query_one(Digits).update(f"{clock:%T}")


if __name__ == "__main__":
    app = ClockApp()
    app.run()

[!TIP] Textual is an asynchronous framework under the hood. Which means you can integrate your apps with async libraries — if you want to. If you don't want or need to use async, Textual won't force it on you.

Widgets

Textual's library of widgets covers everything from buttons, tree controls, data tables, inputs, text areas, and more… Combined with a flexible layout system, you can realize any User Interface you need.

Predefined themes ensure your apps will look good out of the box.

buttons

tree

datatables

inputs

listview

textarea

Installing

Install Textual via pip:

pip install textual textual-dev

See getting started for details.

Demo

Run the following command to see a little of what Textual can do:

python -m textual

Or try the textual demo without installing (requires uv):

uvx --python 3.12 textual-demo

Dev Console

devtools

How do you debug an app in the terminal that is also running in the terminal?

The textual-dev package supplies a dev console that connects to your application from another terminal. In addition to system messages and events, your logged messages and print statements will appear in the dev console.

See the guide for other helpful tools provided by the textual-dev package.

Command Palette

Textual apps have a fuzzy search command palette. Hit ctrl+p to open the command palette.

It is easy to extend the command palette with custom commands for your application.

Command Palette

Textual ❤️ Web

textual-serve

Textual apps are equally at home in the browser as they are the terminal. Any Textual app may be served with textual serve — so you can share your creations on the web. Here's how to serve the demo app:

textual serve "python -m textual"

In addition to serving your apps locally, you can serve apps with Textual Web.

Textual Web's firewall-busting technology can serve an unlimited number of applications.

Since Textual apps have low system requirements, you can install them anywhere Python also runs. Turning any device into a connected device. No desktop required!

Join us on Discord

Join the Textual developers and community on our Discord Server.

textual (Textualize/textual)

Searching Database…

37.5K ·GitHub
这是什么?Textual 是一个轻量的 Python 应用框架:用简单的 Python API 就能构建基于文本的用户界面,做出来的应用既能在终端里运行,也能在网页浏览器里运行。
这是我用来开发应用的框架,还是一个现成的应用?它是一个框架,不是现成的应用:你用 Python 编写界面,由 Textual 负责渲染。它的 API 把现代 Python 和借鉴自 Web 领域的思路结合在一起,让开发保持轻便。
怎么安装,又怎么看它能做什么?先用 pip 安装,然后运行 README 里的演示命令('textual')就能大致看看它的功能。如果你装了 uv,甚至可以不安装 Textual 就直接试用演示。
用它还得写 async 代码吗?不用——只要会 Python 就行。Textual 内部是异步实现的,但用不用 async 是可选的,它不会逼你写异步代码。
在终端里跑界面有什么坑?最大的麻烦是调试:应用占着终端,你就没法在同一处看它的输出。单独的 textual-dev 包可以在另一个终端里给你一个开发控制台,显示事件、日志和 print 输出。
我能给自己的应用写自动化测试吗?可以。Textual 自带一套先进的测试框架,而且它的各个组件是解耦的,方便你长期维护应用。
ctrl+p 命令面板是干什么用的?每个 Textual 应用都有按 ctrl+p 呼出的模糊搜索命令面板,而且很容易为你的应用扩展自定义命令。
这个项目还在活跃维护吗?看起来很健康:创建于 2021 年 4 月,大约 37.4k 星标,未被归档,有格式化、CodeQL 和 Python 打包的 CI 工作流。还有一个活跃的 Discord 社区。
What are similar projects?FTXUI, rich, ratatui, ava, iced, tui-rs, lazy.nvim, gitui
Creator
Textualize
Size
485 MB
Stars
37.5K
Age
5y
Commits · 90 Days