This release is a pre-release and may not be stable for production use.
InteracTUI
Build interactive TUI applications based on the curses library.
InteracTUI provides a base App class that encapsulates a single-column layout made of Views.
Example
A basic TUI might look like :
from interactui import App, View
from interactui.view import Select, TextArea
def quit_function(app: App, _view: View) -> None:
app.print("Bye !")
app.exit(0)
App().run([
TextArea("👋 Hi form InteracTUI"),
Select(
"What do you want to do ?", # title
["Not much", ("Quit", quit_function)] # options, with optional callback on selection
)
])
Views
An app's layout is a collection of View objects. You can define your own views by inheriting from the View class or you can use one of the predefined views :
Select- select an option from multiple optionsMultiSelect- select one or more options from a checkbox-style list of optionsTextArea- display textTextAreaWithButton- display text with a dismissal buttonFloatingView- base for floating views
Key-bindings
Apps and Views can define attached key-bindings with associated callback functions executed on the key press.
Key-bindings are defined in the _key_bindings class variable.
class App: # or View
_key_bindings: ClassVar[list[KeyBinding]] = [...]
...
A key-bindings is made of :
- a
Key - a description
- a callback function
(App | View, Key, App) -> None
An App comes with the following base key-bindings:
<Ctrl-d>- Exit the app<Ctrl-k>- show key bindings
Predefined Views come with their key-bindings but you can also define your own. When inheriting form the View class, add your key-bindings in the _key_bindings class variable.
Style
The appearance of Views can be customized with the style parameter, taking a Style dictionary with the following format:
class Style(TypedDict, total=False):
# all sides | (top & bottom, left & right) | (top, right, bottom, left)
margin: SidesAmount
# all sides | (top & bottom, left & right) | (top, right, bottom, left)
padding: SidesAmount
# border:
# - "none": no border
# - "rounded": rounded corners
# - "squared": squared corners
border: Corner
# foreground font color
color: Color
# one or more font modifiers:
# - "bold"
# - "italic"
# - "dim"
# - "blink"
# - "reverse"
font_modifier: Modifier | tuple[Modifier, ...]
# background font color
background: Color
# number lines | "x%" where x is in (0, 1), percentage of total height
height: int | str
# number columns | "x%" where x is in (0, 1), percentage of total width
width: int | str
Installation
pip install interactui or uv add interactui
Metadata
Release files for interactui 0.1.0rc2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| interactui-0.1.0rc2.tar.gz | 12.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| interactui-0.1.0rc2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.2 kB
Release files / interactui-0.1.0rc2.tar.gz
| Download URL | interactui-0.1.0rc2.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f57cd1707bc7247f471ce591d4d20c1ac11c6918bbc4e5b0f9acd81595e29857
|
|
BLAKE2b-256 checksum How to use checksums |
24d8245822515bc4c0b519102b31d78fab3993ef1419872465c67ca92ff63283
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / interactui-0.1.0rc2-py3-none-any.whl
| Download URL | interactui-0.1.0rc2-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
06ac55c6b4e21c2135eb217669cb3fd6d748020e210c3c93802f2dadb5fa9c70
|
|
BLAKE2b-256 checksum How to use checksums |
d79cdc8f11153ba564308900cf69324ba04833cd780eb745ae86fb36026f9511
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|