dirtywords

portable text interface framework  https://pypi.python.org/pypi/dirtywords
git clone https://git.ce9e.org/dirtywords.git

NameSize
.gitignore76B
CHANGELOG.rst340B
MANIFEST.in19B
README.rst1513B
dirtywords/__init__.py310B
dirtywords/base.py8973B
dirtywords/constants.py577B
dirtywords/curses.py2891B
dirtywords/pygame.py2826B
dirtywords/stupid.py3135B
docs/Makefile6787B
docs/make.bat6718B
docs/source/conf.py8375B
docs/source/index.rst567B
example.py1790B
setup.cfg261B
setup.py904B
tests/__init__.py0B
tests/shared_core.py2572B
tests/test_curses.py645B
tests/test_pygame.py624B
tests/test_stupid.py336B
tox.ini414B

dirtywords - portable text interface framework

So I wanted to create a text interface and ended up creating a framework. "Why didn't you just stick with curses?" I hear you ask. For two good reasons: First, curses is not very portable. It does not run on windows. And it can not be installed with pip. The second reason of course is that I had fun with this project.

So what is this if not curses? You can think of it as a wrapper around curses with a different (though similar) API. But the interesting thing about it is that it implements a tiny set of functions with curses and builds the rest from there. And this tiny core can easily be implemented with other frameworks.

There are currently three implementations of the core: One based on curses, another one based on pygame, and a minimal implementation without any dependencies outside of the standard library.

Example

::

import sys
from dirtywords import Screen, AttrString

text = AttrString(u'Hello World!', fg_color=(0, 255, 0))
screen = Screen(3, len(text) + 4)
screen.border()
screen.putstr(1, 2, text)
screen.refresh()

while True:
    ch = screen.getch()
    if ch == ord('q'):
        screen.cleanup()
        sys.exit()

Tests

In order to run the tests you need to have python-xlib installed. Then you only need to run the following command::

tox --sitepackages

.. _curses: https://docs.python.org/2/library/curses.html .. _pygame: http://pygame.org