Skip to main content

badge-total-downloads badge-monthly-downloads


sty_demo

Release 1.0.6 (November 27. 2023)

Code Changes:

  • Use PEP-484 compatible exports to satisfy static type checkers.

Release 1.0.5 (November 22. 2023)

Code Changes:

  • Add py.typed file for better typing support. Thanks! @Eisfunke

  • Use explicit imports: from .lib import is now from sty.lib import.

  • More and better doc-strings. help(x) should be much more useful now.

Other:

  • Add svg logo. Thanks! @kubinka0505

  • Replace pipenv with poetry.

  • Remove make.py build system.

  • Remove all dev dependencies.

Description

Sty’s goal is to provide Python with a simple, customizable and performant string styling markup, which is decoupled from color palettes and terminal implementations.

  • Sty supports 3/4bit, 8bit and 24bit (truecolor/RGB) colors as well as effects like bold, italic, underline, etc.

  • Sty should work on most Unix platforms with most terminals. It works with recent Windows terminals. Window legacy terminal (cmd) needs a shim to work.

  • Sty comes with default color palettes and renderers, but you can easily replace/customize them, without touching the markup in your code.

  • Sty allows you to mute/unmute all styles in your codebase.

  • Sty provides high access performance for all styling rules.

  • Sty is fully typed, you should get good editor support for it.

  • Sty does not implicitly mess with globals. E.g.: colorama overrides sys.stdout which causes a lot of trouble.

  • Sty has no dependencies.

  • Sty follows semver.

  • Sty will support Python >=3.7 for as long as possible.

If you run into compatibility problems with sty, please file an issue!

Code Example

from sty import fg, bg, ef, rs

foo = fg.red + 'This is red text!' + fg.rs
bar = bg.blue + 'This has a blue background!' + bg.rs
baz = ef.italic + 'This is italic text' + rs.italic
qux = fg(201) + 'This is pink text using 8bit colors' + fg.rs
qui = fg(255, 10, 10) + 'This is red text using 24bit colors.' + fg.rs

# Add custom colors:

from sty import Style, RgbFg

fg.orange = Style(RgbFg(255, 150, 50))

buf = fg.orange + 'Yay, Im orange.' + fg.rs

print(foo, bar, baz, qux, qui, buf, sep='\n')

The code above will print like this in the terminal:

example

You can use the Register class or the default registers FgRegister, BgRegister, EfRegister and RsRegister to create your own registers:

# Extending the default FgRegister

from sty import FgRegister, Style, RgbFg, Sgr

class MyFgRegister(FgRegister):

    def __init__(self):
        super().__init__()

        self.purple = Style(Sgr(35))
        self.blue = Style(Sgr(34))
        self.orange = Style(RgbFg(255, 128, 0))
        # ...

 fg = MyFgRegister()

Documentation

Documentation-Website: https://sty.mewo.dev

Documentation-Website-Source: https://github.com/feluxe/sty-docs

Download files

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

Source Distribution

sty-1.0.6.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sty-1.0.6-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file sty-1.0.6.tar.gz.

File metadata

  • Download URL: sty-1.0.6.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.5 Linux/6.6.1-arch1-1

File hashes

Hashes for sty-1.0.6.tar.gz
Algorithm Hash digest
SHA256 d43ecb71b7bad0b56d622cb219d0be303c16fcb4143b84d1465ded22e29baa00
MD5 03aa57e78f0cad6322f1d801e987aca4
BLAKE2b-256 766aaad1817e60f07e5ebc111affee15d4dff9d324981005310566c40f08786c

See more details on using hashes here.

File details

Details for the file sty-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: sty-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.5 Linux/6.6.1-arch1-1

File hashes

Hashes for sty-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2b1eba187b3961644f797f97177f939c109c916d3d3a2cb6784454d1f1ce4983
MD5 80ade07dff9804a908bfd970a1aef1c7
BLAKE2b-256 ec8922b3b7f25f67d04690e3b565ca89062a6e7afb1e7124342d5b5b22e8f014

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 files

1.0.5

1 file

1.0.4

1 file

1.0.3

1 file

1.0.2

1 file

1.0.1

1 file

1.0.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page