textual

TextualizeMIT活跃维护

用简洁的 Python API 构建复杂终端界面,同一套代码还能跑在浏览器里,适合做 TUI 和命令行应用。

The lean application framework for Python. Build sophisticated user interfaces with a simple Python API. Run your apps in the terminal and a web browser.

v8.2.8发布于 2026-06-30 06:53 UTC37,621star +18 / 7 天1,399fork同步于 2026-11-10 05:19 UTC

怎么上手

从 README 代码块原样提取,可能是其中一种安装方式
pip install textual textual-dev
硬件要求

README 没有说明硬件要求。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

这个项目的说明还在生成中,先参考下面「最近发版」和 README。

最近发版

5 个版本v8.2.8
  1. v8.2.8The more super release最新正式版2026-06-30 · 2026-06-30 06:53 UTC

    Fixes for extended key processing, and a crash bug for clicking the screen padding area.

    [8.2.8] - 2026-06-30

    Fixed

    Changed

  2. v8.2.7The more Kitty Release2026-05-19 · 2026-05-19 10:57 UTC
    查看更新说明

    This release adds additional support for the Kitty key protocol. Which enables some additional keys on some terminals. Additionally, Textual will report modifier keys as separate key events.

    Additionally there are a few more shortcuts to the Text Area.

    This release sponsored by Mistral AI. See release notes for detail.

    [8.2.7] - 2026-05-19

    Added

    Changed

  3. v8.2.6The more selective release2026-05-13 · 2026-05-13 09:58 UTC
    查看更新说明

    Improved text select logic. You can select text without first clicking on a content area.

    May break snapshots without affecting appearance.

    [8.2.6] - 2026-04-13

    Fixed

    Added

  4. v8.2.5The Antsy Release2026-04-30 · 2026-04-30 08:06 UTC
    查看更新说明

    This release adds support for dedicated ansi themes, which are also exposed from the command palette.

    There were a few tweaks to the theming system which may result in broken snapshots, but there should be no visual changes.

    [8.2.5] - 2026-04-30

    Added

    Changed

  5. v8.2.4The small potatoes Release2026-04-19 · 2026-04-19 04:21 UTC
    查看更新说明

    Small potatoes update, to fix a glitch with anchor.

    [8.2.4] - 2026-04-19

    Added

    Fixed

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Discord Supported Python Versions PyPI version OS support

    textual-splash

    Textual

    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

    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 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.