This release is a pre-release and may not be stable for production use.
xnano
A fun, fast and incredibly flexible terminal UI library for Python, built on ratatui.
Quick start
import xnano
from xnano.context import Context
from xnano.expressions import ParentWidth, TimeElapsed, Width
with xnano.open(width=40, height=5) as terminal:
terminal.write('Hello, world!', x='center', border='rounded')
ball = terminal.write('●', y=4)
ball.x = (ParentWidth - Width) * (TimeElapsed % 2 / 2) # a formula, evaluated every frame
@terminal.on_key('space')
def toggle(context: Context) -> None:
if terminal.is_paused:
terminal.resume()
else:
terminal.pause()
terminal.run(quit_on='q')
xnano.open() gives you a terminal. You write text, widgets, images and pixels to it, and every
position and size can be a number, a word such as 'center', or a formula of time or of the
terminal's size. Decorators named for what happens (on_key, on_click, every, after)
react, terminal.input tells a game which keys are held, terminal.scene() gives pixel-art
worlds a camera and collision, and terminal.play('C4 E4 G4:2') plays a melody written as text.
There are no base classes to subclass and no layout tree to declare.
The examples/ folder has twenty-one runnable programs, from hello world to a
playable pixel-art world, and examples/README.md shows what each one draws.
See it
Run the demo in your terminal with python -m xnano (or the xnano command). It opens with an
animation, then fills the window with live panels that each use a different part of xnano.
Every picture below is a real terminal window running one of the programs in
examples/, photographed by make readme-images, so each picture and its
source stay in step.
A playable world
A pixel-art character, a camera that follows it, collision and a clock you can stop: about
one screen of code (20_world.py).
Pixel art that fits the window
Give an image a percentage and it refits whenever the window is resized, keeping its hard pixel
edges; give it a number and it is locked. The thumbnail in the corner is locked
(24_dusk.py). The art is "Mountain at Dusk" by Luis Zuno (ansimuz), CC0.
Pixel art written as text
from_art turns a block of characters and a short palette into an image
(23_sprites.py).
Images and animations
Pan and zoom over a large picture with the arrow keys and + / -
(06_images.py).
Sound
Every built-in instrument, playable from the keyboard (10_audio.py),
and a whole song written as text, played on the beat (22_song.py).
Widgets
Charts, tables and gauges refreshed from a timer (14_dashboard.py).
Install
Install xnano with pip or uv. Sound and images are extras, so a program that needs neither
installs neither:
pip install xnano # the terminal, widgets, effects and events
pip install "xnano[audio]" # adds notes, melodies, sounds and the microphone
pip install "xnano[image]" # adds images and animations
pip install "xnano[audio,image]"
# or
uv add "xnano[audio,image]"
Using sound or images without their extra raises an ImportError that names the extra to
install. On Linux, audio device playback requires ALSA; synthesis and melody scheduling work
without an audio device.
Packages
The repository is a uv workspace with three installable backends and a small xnano
metapackage that holds the terminal API. The backends can also be installed on their own.
| Distribution | Import | Purpose |
|---|---|---|
xnano |
xnano |
The terminal API: open, placements, hooks, input, pixels, scenes and sound. |
xnano-core |
xnano_core |
The Rust-backed engine: buffers, widgets, layout, state, input, runtime and effects. |
xnano-audio |
xnano_audio |
Audio synthesis, playback, capture and beat-based melodies. |
xnano-image |
xnano_image |
Image and animation decoding, processing and terminal-cell conversion. |
Names live in modules named for what they hold, so the top-level xnano stays small:
xnano.widgets, xnano.expressions, xnano.effects, xnano.operations, xnano.styles,
xnano.events, xnano.geometry, xnano.buffers, xnano.scene, xnano.types and
xnano.errors, plus the optional xnano.audio and xnano.image.
xnano v1
xnano v1 (the declarative grid-and-field API) is not part of this branch. It is maintained on
the v1 branch, and the latest release is
v1.2.3
(PyPI):
pip install "xnano>=1.2.3,<2"
The v1 guides are kept in docs/v1, and their code imports from xnano, as v1
did. A program written for v1 must be rewritten for v2.
Development
The repository uses a uv workspace and Rust workspace. From the repository root, uv sync --all-extras
installs the development environment and make help lists common build, test, lint, type-check,
docs and release commands. Read CONTRIBUTING.md before opening a change.
License
xnano is released under the MIT License.
Metadata
Release files for xnano 2.0.0b2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| xnano-2.0.0b2.tar.gz | 11.7 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xnano-2.0.0b2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.2 MB
Release files / xnano-2.0.0b2.tar.gz
| Download URL | xnano-2.0.0b2.tar.gz |
|---|---|
| Size | 11.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e138db0c126ca51e14658094b75b8a4ea695051c8d6a3da687fc15a8270497e8
|
|
BLAKE2b-256 checksum How to use checksums |
ae55b0b7afc432f157c7108c0fe38713020f0643a05b119f4a3f2edaa1d6973f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / xnano-2.0.0b2-py3-none-any.whl
| Download URL | xnano-2.0.0b2-py3-none-any.whl |
|---|---|
| Size | 422.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3ee6958ae69bb2a8fccdf308b646025758124b854e6bee569f0e14e9347d968
|
|
BLAKE2b-256 checksum How to use checksums |
43f1f956d23dd3eac4087ac3df13cc94f8da86e829f63e3caae0aa9e83cffb5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for xnano 2.0.0b2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.