Native GPU-accelerated Terminal control for Flet using xterm.dart
Project description
flet-terminal
A native, GPU-accelerated terminal control for Flet, built on top of xterm.dart.
flet-terminal provides high-performance VT100/ANSI terminal emulation across Windows, Linux, macOS, Android, and Web, utilizing low-latency binary DataChannel streaming to render thousands of lines per second without UI freezing.
Download Flet Terminal
Try the standalone Flet Terminal desktop application directly on your OS:
| Platform | Download | Notes |
|---|---|---|
| 🪟 Windows (x64) | FletTerminal_windows_x64.zip | Portable Windows executable (.exe) |
| 🐧 Linux (x86_64) | FletTerminal_linux_x86_64.tar.gz | Universal Linux tarball (tar -xzf) |
| 📦 All Releases | View Releases Page | Changelog and release notes |
Features
- High-Throughput Binary Streaming: Routes terminal data over Flet
DataChanneldirectly to thexterm.dartcanvas, bypassing string/MsgPack serialization overhead. - Cross-Platform Compatibility: Full feature parity across Desktop (
pty/winpty), Mobile (Android), and Web (WASM/Pyodide). - Responsive Mobile Wrapper & Zoom Controls:
MobileTerminalincludeszoom_in(),zoom_out(),reset_zoom(), and a customizable virtual accessory keyboard (ESC,TAB,CTRL,ALT, arrows) with sticky modifier toggles and collapsible state. - Dynamic Checkmarks & Built-in Themes: Supports instant switching between built-in color schemes (
Dracula,JetBrains Dark,Matrix Green), customizable font families (JetBrains Mono), cursor shapes (block,underline,bar), and cursor blink. Settings popup displays accurate checkmarks (checked=True) that dynamically tick as options change. - Interactive Search & Selection: Built-in buffer search (
search), scrollback control, and clipboard integration (select_all,clear_selection, right-click copy/paste).
Installation
Install via pip:
pip install flet-terminal
Or using uv:
uv add flet-terminal
Quickstart
1. Basic Terminal (Terminal)
import flet as ft
from flet_terminal import Terminal, BUILTIN_THEMES
def main(page: ft.Page):
page.theme_mode = ft.ThemeMode.DARK
term = Terminal(
scrollback=10000,
font_family="JetBrains Mono",
font_size=13.0,
cursor_style="block",
cursor_blink=True,
theme=BUILTIN_THEMES["Dracula"],
expand=True,
)
# Handle incoming bytes typed or pasted into the terminal
def on_terminal_input(data: bytes):
# Echo back or forward to a local OS shell / PTY process
term.send_bytes(data)
term.set_on_bytes(on_terminal_input)
page.add(term)
term.write("\x1b[1;32mWelcome to FletTerminal!\x1b[0m\r\n> ")
ft.run(main)
2. Responsive Mobile Wrapper (MobileTerminal)
MobileTerminal combines the core Terminal with a virtual extra-keys bar, sticky modifier buttons (CTRL, ALT), settings menu, and search bar:
import flet as ft
from flet_terminal import MobileTerminal, BUILTIN_THEMES
def main(page: ft.Page):
mt = MobileTerminal(
show_extra_keys=True,
show_search=True,
show_settings=True,
scrollback=10000,
font_family="JetBrains Mono",
font_size=13.0,
theme=BUILTIN_THEMES["JetBrains Dark"],
expand=True,
)
def on_bytes(payload: bytes):
mt.send_bytes(payload)
mt.set_on_bytes(on_bytes)
page.add(mt)
ft.run(main)
API Reference
Terminal Properties
| Property | Type | Default | Description |
|---|---|---|---|
scrollback |
int |
10000 |
Maximum number of scrollback lines retained in the ring buffer. |
font_family |
str |
"JetBrains Mono" |
Monospace font family for rendering text. |
font_size |
float |
13.0 |
Font point size. |
cursor_style |
str |
"block" |
Cursor shape ("block", "underline", or "bar"). |
cursor_blink |
bool |
True |
Whether the terminal cursor blinks continuously. |
theme |
dict |
None |
Dictionary mapping ANSI color keys to hex/int colors. |
read_only |
bool |
False |
When True, disables user keyboard input into the terminal canvas. |
auto_focus |
bool |
True |
Automatically focuses the terminal when mounted. |
Terminal Methods
| Method | Arguments | Description |
|---|---|---|
send_bytes(payload) |
bytes |
Sends binary data directly over the DataChannel to the terminal canvas. |
write(data) |
str | bytes |
Writes text or escape sequences to the terminal. |
clear() |
— | Clears the terminal scrollback and visible screen buffer. |
focus() |
— | Requests keyboard focus on the terminal control. |
search(query, start) |
str, int |
Highlights and selects matching text in the scrollback buffer. |
select_all() |
— | Selects all text currently in the buffer. |
clear_selection() |
— | Clears any active selection. |
Terminal Events
| Event | Handler | Description |
|---|---|---|
on_data |
Callable[[ft.ControlEvent], None] |
Triggered when string-based text input occurs. |
on_resize |
Callable[[ft.ControlEvent], None] |
Fired when dimensions change. Event data contains JSON {"cols": int, "rows": int}. |
on_title_change |
Callable[[ft.ControlEvent], None] |
Triggered when OSC 0/2 title escape sequences are received. |
on_bell |
Callable[[ft.ControlEvent], None] |
Triggered when the bell character (\a / 0x07) is received. |
on_selection_change |
Callable[[ft.ControlEvent], None] |
Fired when selection or search matches update. |
Built-in Themes
You can import and pass built-in presets from flet_terminal.themes:
from flet_terminal import BUILTIN_THEMES, get_theme
# Available: "Dracula", "JetBrains Dark", "Matrix Green"
my_theme = get_theme("Dracula")
License
This project is licensed under the MIT License. See LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flet_terminal-0.2.2.tar.gz.
File metadata
- Download URL: flet_terminal-0.2.2.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87eeca4d3d83c7310abba29b133b1d255e8f624e3ed7cbf107c038cf36fd1962
|
|
| MD5 |
f3cd81b453c476a8dd196ddce23b5144
|
|
| BLAKE2b-256 |
e20061c386401393f974a7e770be610bfbc2512160d3eee180987b68a402ad44
|
Provenance
The following attestation bundles were made for flet_terminal-0.2.2.tar.gz:
Publisher:
publish.yml on Nwokike/flet-terminal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flet_terminal-0.2.2.tar.gz -
Subject digest:
87eeca4d3d83c7310abba29b133b1d255e8f624e3ed7cbf107c038cf36fd1962 - Sigstore transparency entry: 2236241729
- Sigstore integration time:
-
Permalink:
Nwokike/flet-terminal@6f2f52cf28fb70049b88f16a408646a2e814241b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Nwokike
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6f2f52cf28fb70049b88f16a408646a2e814241b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file flet_terminal-0.2.2-py3-none-any.whl.
File metadata
- Download URL: flet_terminal-0.2.2-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19cff5a756f375e6fd0d43e87be190b9bfb08a468193f4ba472b88e8554ccf45
|
|
| MD5 |
ae431da0a4fdc47b6c2889f705d4e0a8
|
|
| BLAKE2b-256 |
4a3022cf080aaf12d1b29727f7a119e78ef13236864429ed94fade5c00ee8ce3
|
Provenance
The following attestation bundles were made for flet_terminal-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on Nwokike/flet-terminal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flet_terminal-0.2.2-py3-none-any.whl -
Subject digest:
19cff5a756f375e6fd0d43e87be190b9bfb08a468193f4ba472b88e8554ccf45 - Sigstore transparency entry: 2236241862
- Sigstore integration time:
-
Permalink:
Nwokike/flet-terminal@6f2f52cf28fb70049b88f16a408646a2e814241b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Nwokike
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6f2f52cf28fb70049b88f16a408646a2e814241b -
Trigger Event:
workflow_dispatch
-
Statement type: