Renders Rich console output (Tables, Panels, Layouts) into a full
xterm.js terminal in HTML. Use it to convert any existing TUI into
a desktop app window.
from ObjRichBridge import ObjRichBridge
from ObjDesktopApp import ObjDesktopApp
from rich.table import Table
bridge = ObjRichBridge(width=120, font_size="15px")
def my_dashboard():
table = Table(title="Hosts")
table.add_column("Name", style="cyan")
table.add_column("CPU", justify="right")
table.add_row("mariadb", "[green]4%[/]")
table.add_row("hypervisor", "[yellow]68%[/]")
return table
app = ObjDesktopApp(
title="TUI Dashboard",
render_fn=bridge.wrap(my_dashboard),
poll_interval=30,
)
app.run()
| Parameter | Type | Default | Description |
|---|---|---|---|
width |
int | 160 | Console width in characters |
background |
str | "#0f1923" | Terminal background colour |
font_size |
str | "14px" | Terminal font size |
font_family |
str | Cascadia/Fira/monospace | Terminal font stack |
padding |
str | "16px" | Terminal padding |
Convert Rich objects directly to HTML.
from rich.panel import Panel
from rich.table import Table
html = bridge.render(
Panel("Dashboard", border_style="cyan"),
table,
)
Call a function that returns Rich renderables.
def build_ui():
t = Table()
t.add_column("Host")
t.add_row("mariadb")
return t # or [table, panel, text]
html = bridge.render_fn(build_ui)
The function can return:
None (if it printed to the internal console)Pass a Rich Console to a function that prints directly.
def build_ui(console):
console.print("[bold]Status[/bold]")
console.print(table)
console.rule()
html = bridge.render_console(build_ui)
Return a callable for ObjDesktopApp.render_fn.
app = ObjDesktopApp(
render_fn=bridge.wrap(build_dashboard),
)
Same as wrap but for console-style functions.
app = ObjDesktopApp(
render_fn=bridge.wrap_console(build_tui),
)
force_terminal=Truecolor_system="truecolor" — full ANSI escape sequencesThis gives pixel-perfect TUI rendering with proper box drawing
characters, 24-bit colour, and scrollback — identical to how it
looks in a real terminal.
All Rich renderables work:
Table — data tables with borders and stylingPanel — bordered panels with titlesText — styled text with markupLayout — multi-column layoutsTree — tree structuresSyntax — syntax-highlighted codeMarkdown — rendered markdownProgress — progress bars (static snapshot)Console.rule() — horizontal rules__rich_console__ renderableFor best box drawing character support, use one of:
The default font stack tries all of these in order.