[](https://travis-ci.org/thomasballinger/curtsies)
[](https://readthedocs.org/projects/curtsies/?badge=latest)

Curtsies is a library for interacting with the terminal.
This is what using (nearly every feature of) curtsies looks like:
```python
from __future__ import unicode_literals # convenient for Python 2
import random
from curtsies import FullscreenWindow, Input, FSArray
from curtsies.fmtfuncs import red, bold, green, on_blue, yellow
print(yellow('this prints normally, not to the alternate screen'))
with FullscreenWindow() as window:
with Input() as input_generator:
msg = red(on_blue(bold('Press escape to exit')))
a = FSArray(window.height, window.width)
a[0:1, 0:msg.width] = [msg]
for c in input_generator:
if c == '<ESC>':
break
elif c == '<SPACE>':
a = FSArray(window.height, window.width)
else:
s = repr(c).decode()
row = random.choice(range(window.height))
column = random.choice(range(window.width-len(s)))
color = random.choice([red, green, on_blue, yellow])
a[row, column:column+len(s)] = [color(s)]
window.render_to_terminal(a)
```
Paste it in a `something.py` file and try it out!
Installation: `pip install curtsies`
[Documentation](http://curtsies.readthedocs.org/en/latest/)
Primer
------
[FmtStr](http://curtsies.readthedocs.org/en/latest/FmtStr.html) objects are strings formatted with
colors and styles displayable in a terminal with [ANSI escape sequences](http://en.wikipedia.org/wiki/ANSI_escape_code>`_).
(the import statement shown below is outdated)

[FSArray](http://curtsies.readthedocs.org/en/latest/FSArray.html) objects contain multiple such strings
with each formatted string on its own row, and FSArray
objects can be superimposed on each other
to build complex grids of colored and styled characters through composition.
(the import statement shown below is outdated)

Such grids of characters can be rendered to the terminal in alternate screen mode
(no history, like `Vim`, `top` etc.) by [FullscreenWindow](http://curtsies.readthedocs.org/en/latest/window.html#curtsies.window.FullscreenWindow) objects
or normal history-preserving screen by [CursorAwareWindow](http://curtsies.readthedocs.org/en/latest/window.html#curtsies.window.CursorAwareWindow) objects.
User keyboard input events like pressing the up arrow key are detected by an
[Input](http://curtsies.readthedocs.org/en/latest/input.html) object.
Examples
--------
* [Tic-Tac-Toe](/examples/tictactoeexample.py)

* [Avoid the X's game](/examples/gameexample.py)

* [Bpython-curtsies uses curtsies](http://ballingt.com/2013/12/21/bpython-curtsies.html)
[](http://www.youtube.com/watch?v=lwbpC4IJlyA)
* [More examples](/examples)
About
-----
* [Curtsies Documentation](http://curtsies.readthedocs.org/en/latest/)
* Curtsies was written to for [bpython-curtsies](http://ballingt.com/2013/12/21/bpython-curtsies.html)
* `#bpython` on irc is a good place to talk about Curtsies, but feel free
to open an issue if you're having a problem!
* Thanks to the many contributors!
* If all you need are colored strings, consider one of these [other libraries](http://curtsies.readthedocs.org/en/latest/FmtStr.html#rationale)!
[](https://readthedocs.org/projects/curtsies/?badge=latest)

Curtsies is a library for interacting with the terminal.
This is what using (nearly every feature of) curtsies looks like:
```python
from __future__ import unicode_literals # convenient for Python 2
import random
from curtsies import FullscreenWindow, Input, FSArray
from curtsies.fmtfuncs import red, bold, green, on_blue, yellow
print(yellow('this prints normally, not to the alternate screen'))
with FullscreenWindow() as window:
with Input() as input_generator:
msg = red(on_blue(bold('Press escape to exit')))
a = FSArray(window.height, window.width)
a[0:1, 0:msg.width] = [msg]
for c in input_generator:
if c == '<ESC>':
break
elif c == '<SPACE>':
a = FSArray(window.height, window.width)
else:
s = repr(c).decode()
row = random.choice(range(window.height))
column = random.choice(range(window.width-len(s)))
color = random.choice([red, green, on_blue, yellow])
a[row, column:column+len(s)] = [color(s)]
window.render_to_terminal(a)
```
Paste it in a `something.py` file and try it out!
Installation: `pip install curtsies`
[Documentation](http://curtsies.readthedocs.org/en/latest/)
Primer
------
[FmtStr](http://curtsies.readthedocs.org/en/latest/FmtStr.html) objects are strings formatted with
colors and styles displayable in a terminal with [ANSI escape sequences](http://en.wikipedia.org/wiki/ANSI_escape_code>`_).
(the import statement shown below is outdated)

[FSArray](http://curtsies.readthedocs.org/en/latest/FSArray.html) objects contain multiple such strings
with each formatted string on its own row, and FSArray
objects can be superimposed on each other
to build complex grids of colored and styled characters through composition.
(the import statement shown below is outdated)

Such grids of characters can be rendered to the terminal in alternate screen mode
(no history, like `Vim`, `top` etc.) by [FullscreenWindow](http://curtsies.readthedocs.org/en/latest/window.html#curtsies.window.FullscreenWindow) objects
or normal history-preserving screen by [CursorAwareWindow](http://curtsies.readthedocs.org/en/latest/window.html#curtsies.window.CursorAwareWindow) objects.
User keyboard input events like pressing the up arrow key are detected by an
[Input](http://curtsies.readthedocs.org/en/latest/input.html) object.
Examples
--------
* [Tic-Tac-Toe](/examples/tictactoeexample.py)

* [Avoid the X's game](/examples/gameexample.py)

* [Bpython-curtsies uses curtsies](http://ballingt.com/2013/12/21/bpython-curtsies.html)
[](http://www.youtube.com/watch?v=lwbpC4IJlyA)
* [More examples](/examples)
About
-----
* [Curtsies Documentation](http://curtsies.readthedocs.org/en/latest/)
* Curtsies was written to for [bpython-curtsies](http://ballingt.com/2013/12/21/bpython-curtsies.html)
* `#bpython` on irc is a good place to talk about Curtsies, but feel free
to open an issue if you're having a problem!
* Thanks to the many contributors!
* If all you need are colored strings, consider one of these [other libraries](http://curtsies.readthedocs.org/en/latest/FmtStr.html#rationale)!
Release files for curtsies 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| curtsies-0.2.2.tar.gz | 42.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| curtsies-0.2.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 72.2 kB
Release files / curtsies-0.2.2.tar.gz
| Download URL | curtsies-0.2.2.tar.gz |
|---|---|
| Size | 42.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aabd7524c3dfa165bb896694cb785bcf45d3cbd7663fc1971d17e05a9043856f
|
|
BLAKE2b-256 checksum How to use checksums |
9b30fb7966b49a34020515e977049a45a43fce4de00c70b62771963eed317c1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / curtsies-0.2.2-py2.py3-none-any.whl
| Download URL | curtsies-0.2.2-py2.py3-none-any.whl |
|---|---|
| Size | 29.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f1dca2e692f489ecea5fc4e7e5217878f0c0712feee9f5492e29e953eb9100cc
|
|
BLAKE2b-256 checksum How to use checksums |
c30548efd529b0deb1a8678cc99fc8a557f137d7174d55cb160fa480a8c6449d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |