Skip to main content

Lokutui

Lokutui is a lightweight Python library for building native terminal user interfaces (TUIs) using curses. It provides core screen management, an event system, and a collection of common widgets that can be composed to build interactive text‑based applications.

Installation

Lokutui is distributed via PyPI;

pip install lokutui

Alternatively, include it directly as a dependency in your project or install from source.

Core concepts

Screen

Screen is the entry point for any application. It handles curses initialization, the main loop, input polling, rendering, and event dispatching. Typical usage:

from lokutui.core import Screen

screen = Screen()

# add widgets
# screen.add_widget(my_widget)

screen.run()

The run method accepts an optional initial_setup_callback where you can configure widgets before the loop starts. Call screen.exit() from any handler to terminate the application.

Screen also supports a simple loading overlay and a modal widget you can assign to screen.modal.

Widget

All visual elements inherit from the base Widget class. A widget has position (x, y), optional size (width, height), and visibility. Widgets must implement render(stdscr, max_y, max_x) and may override handle_event(event) to react to input.

Event system

Events are instances of a simple named tuple with type and data. The library provides helpers for creating key, mouse and custom events:

from lokutui.events import create_key_event, CustomEvent

EventDispatcher is a singleton used by the screen to dispatch events to registered handlers. You can register handlers and post events either directly or by using the global queue:

from lokutui.events import EventDispatcher

dispatcher = EventDispatcher()
def on_key(e):
    ...
dispatcher.register_handler('key', on_key)

Handlers are called for each event type when Screen processes the queue.

Widgets

Lokutui includes a number of built‑in widgets located in lokutui.widgets:

  • Label – render static text at a position with optional width and color.
  • Box – draw a bordered rectangle.
  • Frame – a Box with an optional title.
  • Button – clickable text; supports focus/highlight and invokes an on_click callback.
  • TextInput – single‑line editable input field with basic cursor movement and text editing.
  • List – scrollable list of strings; arrow keys or j/k to navigate, ENTER to select.
  • Select – horizontal chooser cycling through options with left/right or h/l keys.
  • Checkbox – toggleable checkbox with label.
  • VStack/HStack – layout containers stacking child widgets vertically or horizontally.
  • Dialog – simple yes/no modal dialog.
  • FormDialog – multi‑field modal form with save/cancel buttons.
  • LogDisplay – scrollable log window for output messages.
  • ProgressBar – horizontal progress indicator.
  • Chart – very basic line chart using braille characters.

Each widget accepts positioning and sizing arguments, color pair indices for curses attributes, and optional callbacks for interactions (on_click, on_select, on_change, etc.).

Example of building a simple form:

from lokutui.core import Screen
from lokutui.widgets import VStack, Label, TextInput, Button

screen = Screen()

name_input = TextInput(x=2, y=2, width=20)
submit = Button("Submit", x=2, y=4, on_click=lambda: screen.exit())

vstack = VStack([Label("Name:"), name_input, submit], x=1, y=1, spacing=1)
screen.add_widget(vstack)

screen.run()

Extending Lokutui

You can subclass Widget to create custom components. Implement rendering logic and event handling as needed and add instances to the Screen.

Contributing

Contributions are welcome. Please open issues or pull requests in the repository and follow standard Python packaging conventions.

License

MIT

Metadata

Release files for lokutui 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lokutui 0.1.7
File Size Uploaded
lokutui-0.1.7.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lokutui 0.1.7
File Interpreter ABI Platform
lokutui-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / lokutui-0.1.7.tar.gz

Download URL lokutui-0.1.7.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
45ca54cf5da4995be3fdc847f5974854eb86db76eb19995a040c520677974bc2
BLAKE2b-256 checksum
How to use checksums
f8a45f3bc37cfa2b1c8d07226a1ff0b91ee5aac0b1915c7503898a1302e0ac81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 26, 2026.

Transparency log

Release files / lokutui-0.1.7-py3-none-any.whl

Download URL lokutui-0.1.7-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ddbdfcf4ae8a947ea3ef1ba26941736f5bbacc0da79b4684b53ec51c38f21e4
BLAKE2b-256 checksum
How to use checksums
0b1bd435f4305fa22813584389a2a6c0a7a910d303fb69528133bb2afc2fc9e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page