Library for TUI programs on basis of curses
Project description
cursedspace
A python library/framework for TUI application on the basis of the curses package.
Example use
Here’s a very simple example of how to use the cursedspace package:
#!/usr/bin/env python3
from cursedspace import Application, Key, Panel, colors
class DemoApplication(Application):
def __init__(self):
super().__init__()
self.panel = None
def main(self):
self.panel = Panel(self)
self.resize()
self.screen.addstr(0, 0, "Just some color example", colors.attr(colors.RED))
while True:
curses.doupdate()
key = self.read_key()
if key == Key.RESIZE:
self.resize()
elif key in [Key.ESCAPE, "q", "^C"]:
break
def resize(self):
height, width = self.size()
self.panel.resize(height, width)
self.panel.paint()
# run the application
DemoApplication().run()
Components
Application
is the main application class and provides boilerplate initialisationsPanel
is a basic panel with support for borders and key handling in the context of anApplication
InputLine
is a panel with very basic editing support.Key
provides a convenient wrapper around curses’ key system. It can be used standalone even when you don’t want to useApplication
orPanel
.ShellContext
is a convenient wrapper to execute external processes (e.g. through subprocess) and returning to the curses context afterwards again.colors
is a generic way to define colors in pairs (foreground and background) and have them automatically registerd for use in curses. You only have to callcolors.attr(ColorPair(...))
to use a new color combination (limited by the terminal, of course).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cursedspace-1.1.0.tar.gz
(13.7 kB
view hashes)
Built Distribution
Close
Hashes for cursedspace-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44eda4a889e7b9f33b7d8657e8eb75cbe41cff98d64a0820f129e974181a33f4 |
|
MD5 | f8a32c406568c71084d6bab028947f1d |
|
BLAKE2b-256 | b738c8db12ecfe7bc27902932091cac1711eaba6f8e04b720734da70892f0d51 |