Skip to main content

Documentation Status Curtsies Logo

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

import random
import sys

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:
    a = FSArray(window.height, window.width)
    msg = red(on_blue(bold('Press escape to exit, space to clear.')))
    a[0:1, 0:msg.width] = [msg]
    window.render_to_terminal(a)
    with Input() as input_generator:
        for c in input_generator:
            if c == '<ESC>':
                break
            elif c == '<SPACE>':
                a = FSArray(window.height, window.width)
            else:
                s = repr(c)
                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.

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

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!

Metadata

Release files for curtsies 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for curtsies 0.4.3
File Size Uploaded
curtsies-0.4.3.tar.gz 53.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for curtsies 0.4.3
File Interpreter ABI Platform
curtsies-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 88.9 kB

Release files / curtsies-0.4.3.tar.gz

Download URL curtsies-0.4.3.tar.gz
Size 53.4 kB
Tags Source
SHA-256 checksum
How to use checksums
102a0ffbf952124f1be222fd6989da4ec7cce04e49f613009e5f54ad37618825
BLAKE2b-256 checksum
How to use checksums
d1185741cb42624089a815520d5b65c39c3e59673a77fd1fab6ad65bdebf2f91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / curtsies-0.4.3-py3-none-any.whl

Download URL curtsies-0.4.3-py3-none-any.whl
Size 35.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65a1b4d6ff887bd9b0f0836cc6dc68c3a2c65c57f51a62f0ee5df408edee1a99
BLAKE2b-256 checksum
How to use checksums
ab9bb8ee3720d056309f4ab667bfc85995c4351f67b22e8c2008612b70350c3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.4.3 This release

2 release files

0.4.2

2 release files

0.4.1

1 release file

0.4.0

1 release file

0.3.10

1 release file

0.3.9

1 release file

0.3.8

1 release file

0.3.7

1 release file

0.3.6

1 release file

0.3.5

1 release file

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

1 release file

0.2.12

1 release file

0.2.11

2 release files

0.2.10

2 release files

0.2.9

1 release file

0.2.8

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

1 release file

0.1.23

2 release files

0.1.22

1 release file

0.1.21

1 release file

0.1.17

1 release file

0.1.16

1 release file

0.1.15

1 release file

0.1.14

1 release file

0.1.13

1 release file

0.1.12

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.36

3 release files

0.0.34

1 release file

0.0.33

1 release file

0.0.32

1 release file

0.0.31

1 release file

0.0.30

1 release file

0.0.29

1 release file

0.0.28

1 release file

0.0.27

1 release file

0.0.26

1 release file

0.0.25

1 release 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