Curses-like terminal wrapper, with colored strings!
Reason this release was yanked:
This version is broken, a bad regex breaks cursor position detection
Project description
|Build Status| |Documentation Status| |Curtsies Logo|
Curtsies is a Python 2.7 & 3.4+ compatible library for interacting with the terminal. This is what using (nearly every feature of) curtsies looks like:
.. code:: python
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 == '': break elif c == '': 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%3E%60_>
__.
|image3|
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)
|image4|
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>
__
|image5|
Avoid the X’s game </examples/gameexample.py>
__
|image6|
Bpython-curtsies uses curtsies <http://ballingt.com/2013/12/21/bpython-curtsies.html>
__
|image7|
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.io/en/latest/FmtStr.html#fmtstr-rationale>
__!
.. |Build Status| image:: https://travis-ci.org/bpython/curtsies.svg?branch=master :target: https://travis-ci.org/bpython/curtsies .. |Documentation Status| image:: https://readthedocs.org/projects/curtsies/badge/?version=latest :target: https://readthedocs.org/projects/curtsies/?badge=latest .. |Curtsies Logo| image:: http://ballingt.com/assets/curtsiestitle.png .. |image3| image:: https://i.imgur.com/bRLI134.png .. |image4| image:: http://i.imgur.com/rvTRPv1.png .. |image5| image:: http://i.imgur.com/AucB55B.png .. |image6| image:: http://i.imgur.com/nv1RQd3.png .. |image7| image:: http://i.imgur.com/r7rZiBS.png :target: http://www.youtube.com/watch?v=lwbpC4IJlyA
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
Built Distribution
File details
Details for the file curtsies-0.3.2.tar.gz
.
File metadata
- Download URL: curtsies-0.3.2.tar.gz
- Upload date:
- Size: 53.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b863246aca6a26a427dd636ea9eee1ff4d3afcf78c62049ab1a675304e3d9b95 |
|
MD5 | 3469e0b115fe625c29595d64c16fee89 |
|
BLAKE2b-256 | 91b4bd1840a78ca6824aaa3b1ab18a0604580ccc2204b241f3e9ab1ec2d7d576 |
File details
Details for the file curtsies-0.3.2-py2.py3-none-any.whl
.
File metadata
- Download URL: curtsies-0.3.2-py2.py3-none-any.whl
- Upload date:
- Size: 35.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf1a58daf255e1f16173f5fd40637c1c188626fce721f9a3cc9b6ade1e07651e |
|
MD5 | 0a9bbc391b89698b59435ca13346a0e6 |
|
BLAKE2b-256 | e55d1b926672e241927bb79ab2aeb310c86106aca75d9c9a2bdcd9c835f7a675 |