Skip to content

Learn

These guides teach xnano, from the first line of code to a finished program. Start with Installation. Then read Your First Program, where we build a small focus timer. The timer uses the main ideas of xnano: a canvas, placements, hooks for keys and time, a widget and a sound. Each guide after it explains one part in more detail.

You need Python 3.10 to 3.14 and a terminal. The guides explain everything else when you need it.

The guides

Guide What you learn
Installation Install xnano and the optional extras for images and sound
Your First Program Write text on a terminal, then make it react to keys and time
Writing Content Set the position, size, box and layer of content
Styling Use colors, text modifiers, styles and borders
Hooks & Input React to the keyboard and the mouse
Time & Effects Use the clock and timers, and animate content with effects
Widgets Show gauges, charts, tables and lists
Images & Pixel Art Draw pixel art and load pictures
Sound Play notes and melodies, and listen to the microphone

Four ideas

All the guides use the same four ideas. Learn them before you start.

  • A canvas is the area that you draw on. xnano.new() makes a canvas in memory, which you can use to draw one frame and print it. xnano.open() shows a canvas in your terminal window and returns it as a terminal.
  • The screen of a canvas, canvas.screen, holds its cells. You write content on it with canvas.write(), which is the same as canvas.screen.write(). The call returns a placement, a live handle on the content that you wrote. When you change the text, color, position or size of a placement, the screen changes too.
  • A hook is a function that xnano calls when something happens, for example a key press, a mouse click or a tick of the clock. xnano gives each hook a context, which holds the event and the devices.
  • A device is one part of a terminal: the screen, the keyboard, the mouse, the clock, the speaker or the microphone. Each canvas has all six devices, and each context has them too.

Words in these guides

Word Meaning
cell One character position on the screen. Positions and sizes are in cells.
frame One drawing of the screen.
widget Ready-made content, such as a gauge, a chart, a table or a list.
expression A value that xnano calculates again on each frame, such as terminal.clock / 60.
effect An animation on content, such as a fade or a sweep.
layer A level of content. Content on a higher layer covers content on a lower layer.
extra An optional part of xnano that you install separately, such as xnano[image].

The API reference gives every function, class and parameter.