Works
02 · Python

ConsoleUI

Build terminal apps the way you build GUIs. A text-mode toolkit for Python: add widgets, run the loop, and get focus, menus, dropdowns, dialogs, mouse and keyboard. It runs over ssh and needs nothing but Python.

0
dependencies
42
widgets
10
themes
3
languages
927
tests
  1. 01CellsA grid of characters. Every widget draws into it.
  2. 02WidgetsForty-two kinds. Buttons, tables, trees, charts, dialogs.
  3. 03RendererOnly the cells that changed are sent. Quick over ssh.
  4. 04InputKeyboard, mouse and focus, on Windows and POSIX.
  5. 05Themes, languagesTen themes, three languages. Each one is a plain file.

ConsoleUI keeps a grid of character cells. Widgets draw into it, and the library turns the changes into terminal codes. Only changed cells are sent, so it stays quick on a slow link.

You place widgets at cell positions, give them callbacks and start the loop. Tab moves focus, Alt keys press buttons, the mouse clicks and scrolls, and a dialog blocks the way a GUI dialog does.

It is one Python package with no third-party dependencies. Copy it into a project and it works, on Windows 10 or later and on POSIX terminals, in truecolor.

login.pyPython 3.9+
from console_ui import App
from console_ui.widgets import Panel, Button, Checkbox, TextInput

app = App(theme="splunkyard")
app.add(Panel(2, 2, 40, 7, "Login"))
app.add(TextInput(4, 4, w=30, value="admin"))
app.add(Checkbox(4, 6, "&Remember me", checked=True))
app.add(Button(4, 8, "&Sign in", "primary",
               on_activate=lambda a: a.message_box(
                   "success", "OK", ["Signed in."])))
app.add(Button(15, 8, "&Quit", on_activate=lambda a: a.quit()))
app.run()

Every screenshot on this page is a real frame from the shipped demos, read out of the library's own screen buffer and drawn cell by cell. Nothing is a mock-up.

ConsoleUI kitchen sink demo: panels, buttons, checkboxes, sliders, tables and progress bars in one terminal screen.
The kitchen sink. Buttons, checkboxes, radios, sliders, tables and progress bars in one screen.

Forms check as you type. Errors show inline, and a help pane follows the field you are on.

A form with validated fields, inline errors, a live help pane and an activity log.
Validated fields with inline errors, a live help pane and an activity log.

Dense on purpose. Titles sit on the borders and a one-row chrome mode gives the last line back. Real admin forms fit in 24 rows.

Dense mode: a full form in a 24-row terminal.
Dense mode. One chrome row, titles on the borders, a form in 24 rows.

A list that filters as you type, with a preview beside it.

A filter-as-you-type list with a highlighted text preview.
Search and preview. A filter-as-you-type list with a highlighted text preview.

Rest the pointer on a control, or press F1. One global delay keeps tooltips calm.

A tooltip open over a control in a terminal form.
Tooltips on hover, or F1 when there is no mouse.

Ten themes. A theme is a file of named colour roles, so no widget needs restyling. Switch at run time from the menu.

Splunkyard screenshot
The kitchen-sink screen in the Splunkyard Dark theme.

The parts that usually cost a week come built in: menus with accelerators, context help, a command palette, a calendar and a file dialog.

System menu screenshot
The built-in menu: help, theme, language, about and quit.

English, Hungarian and German ship in the box. A new language is one file. Switch live and the whole screen repaints, month names and menu letters included.

Magyar: menu screenshot
Hungarian. The system menu, translated, with its own accelerators.
Inside

Forty-two widgets

Five families: basics, input, data and charts, layout, forms and feedback. Labels, buttons and lists sit next to trees, sparklines, a braille drawing surface, a hex viewer and split panes.

Dialogs, toasts, tooltips, a menu bar and an F-key bar come with them. Every widget draws from theme roles.

A page can also be described in JSON, loaded into live widgets and saved back. That round trip is tested for every widget.

About ten thousand lines in a dozen modules, and 927 tests that drive the real event loop with scripted keys, no terminal needed. Source stays private.