Skip to main content

Build Status Documentation Status Curtsies Logo

Curtsies is a library for interacting with the terminal. This is what using (nearly every feature of) curtsies looks like:

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

Primer

FmtStr objects are strings formatted with colors and styles displayable in a terminal with ANSI escape sequences.

(the import statement shown below is outdated)

FSArray 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 objects or normal history-preserving screen by CursorAwareWindow objects. User keyboard input events like pressing the up arrow key are detected by an Input object.

Examples

image3

About

  • Curtsies Documentation

  • Curtsies was written to for bpython-curtsies

  • #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!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

curtsies-0.2.8.tar.gz (44.4 kB view details)

Uploaded Source

File details

Details for the file curtsies-0.2.8.tar.gz.

File metadata

  • Download URL: curtsies-0.2.8.tar.gz
  • Upload date:
  • Size: 44.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for curtsies-0.2.8.tar.gz
Algorithm Hash digest
SHA256 23618d67f3b392f524f528c762e77b4a0c049292d7f84e06be3d2470ee0a067b
MD5 c82877dac3506036f1ff8f33b1e0e5a3
BLAKE2b-256 f39e1742e93eb3b56390f44fbdc342c98cefe357735762d1479afa5873d3d88e

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.3

2 files

0.4.2

2 files

0.4.1

1 file

0.4.0

1 file

0.3.10

1 file

0.3.9

1 file

0.3.8

1 file

0.3.7

1 file

0.3.6

1 file

0.3.5

1 file

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

1 file

0.2.12

1 file

0.2.11

2 files

0.2.10

2 files

0.2.9

1 file

This release

0.2.8 This release

1 file

0.2.6

1 file

0.2.5

1 file

0.2.4

1 file

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

1 file

0.1.23

2 files

0.1.22

1 file

0.1.21

1 file

0.1.19

2 files

0.1.18

2 files

0.1.17

1 file

0.1.16

1 file

0.1.15

1 file

0.1.14

1 file

0.1.13

1 file

0.1.12

1 file

0.1.11

1 file

0.1.10

1 file

0.1.9

1 file

0.1.8

1 file

0.1.7

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

0.0.36

3 files

0.0.34

1 file

0.0.33

1 file

0.0.32

1 file

0.0.31

1 file

0.0.30

1 file

0.0.29

1 file

0.0.28

1 file

0.0.27

1 file

0.0.26

1 file

0.0.25

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page