Skip to main content

A simple output styler in Python

Project description

How to use

Requirements

  • Python 3.6 or more
  • Windows*

How to use

First install with pip

pip install styleio

Now import

import styleio

First, you need to think about how your text will look like. You can have text styled. Just simply enter one of bold, dim, italic, underline, blink, inverse, hidden, or strikethrough

Now, color your text. Color is optional, but you have four color mode choices: rgb**, 256 colors**, 16 colors, and bright colors***

*I have not tested on an operating system without windows, feel free to open an issue with the readme saying otherwise on github **RGB and 256 color modes do NOT support styled text ***Only terminals that support the aixterm specification (mine did) support brightcolors

If you have rgb colors, the mode will be 'rgb' and the color will be a tuple of (r, g, b), where 0 <= r, g, b, <= 255, and the mode will be 'rgb' If you have 256 colors, the mode will be 'colors256' and the color will be an id 0 <= id <= 255, where each id means these colors: 0-7: standard colors (as in ESC [ 30–37 m) 8–15: high intensity colors (as in ESC [ 90–97 m) 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5). Some interpret these as constant increments, while others have specific values for each one 232-255: grayscale from dark to light in 24 steps.

With 16 colors (normal, recommended), the mode will be 'colors16', and color will be one of 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default' Bright colors are just like 16 colors, its just that they will look brighter on the terminal and the mode is 'brightcolors'

Styling the text

First, specify the list of styles

graphics = ['bold', 'italic']

Next, specify the color. Say I want bright red

color = 'red'
mode = 'brightcolors'

Now, finally style the output for a italicized bold bright red "Hello, World" message to appear.

string = style(
    text="Hello, World",
    graphics=graphics,
    color=color,
    mode=mode
)
print(string)

Project details


Download files

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

Source Distribution

styleio-0.0.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

styleio-0.0.3-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file styleio-0.0.3.tar.gz.

File metadata

  • Download URL: styleio-0.0.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for styleio-0.0.3.tar.gz
Algorithm Hash digest
SHA256 880c730a443bd4122c32bc40c92db67503fb9718e69baa7f8c415bb92746878d
MD5 272373827ccffe5faf7df699792f0b53
BLAKE2b-256 724dd8198f5d171e4c3d86db5c9e03ad62ffcf5faf0354cab61db762ae95d661

See more details on using hashes here.

Provenance

The following attestation bundles were made for styleio-0.0.3.tar.gz:

Publisher: python-publish.yml on anaphan1/styleio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file styleio-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: styleio-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for styleio-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 619884f494900190f00aca314c3933f83e52721e16be8111a43274ff99987dbd
MD5 88f7e20e8046be1d927c88e171831b37
BLAKE2b-256 fae6af43f766c7a84ff9768891e9c6133eb0ff2f1bc28c405825c4d7b2687fe0

See more details on using hashes here.

Provenance

The following attestation bundles were made for styleio-0.0.3-py3-none-any.whl:

Publisher: python-publish.yml on anaphan1/styleio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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