Skip to main content

A Python library for terminal-colored text with 256-color and truecolor support

Project description

rgbterminal

rgbterminal is a lightweight Python library for terminal-colored text with both 256-color and truecolor (24-bit) support. It allows you to print colorful text in the terminal easily, with a convenient factory system for repeated colors.


Features

  • Foreground 256-color and truecolor support
  • Easy-to-use factory for creating multiple colored texts
  • Access RGB values, cube levels, and terminal color codes
  • Compatible with Python 3.10+

Installation

Install via pip:

pip install rgbterminal

Usage

Basic Usage

from rgbterminal import RGBText

# 256-color text
text1 = RGBText("Hello 256-color!", rgb=(120, 200, 80), truecolor=False)
print(text1)

# Truecolor text
text2 = RGBText("Hello Truecolor!", rgb=(120, 200, 80), truecolor=True)
print(text2)

Using RGBTextFactory

from rgbterminal import RGBTextFactory

factory = RGBTextFactory((255, 100, 50))

# Generate multiple texts with same base color
t1 = factory.t("Factory 256-color text")
t2 = factory.t_truecolor("Factory Truecolor text")
t3 = factory.text("Another 256-color text")

print(t1)
print(t2)
print(t3)

# Access properties
print("Factory RGB:", factory.r, factory.g, factory.b)
print("Cube levels:", factory.r_level, factory.g_level, factory.b_level)
print("256-color code:", factory.code)

Properties

For any RGBText object:

  • r, g, b → RGB values (0-255)
  • r_level, g_level, b_level → Cube levels (0-5)
  • red, green, blue → aliases for r, g, b
  • red_level, green_level, blue_level → aliases for cube levels
  • code → 256-color terminal code
  • in_256color → 256-color string for printing

Contributing

Contributions are welcome! Please fork the repo and submit a pull request.


License

MIT License

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

rgbterminal-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

rgbterminal-0.1.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file rgbterminal-0.1.1.tar.gz.

File metadata

  • Download URL: rgbterminal-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for rgbterminal-0.1.1.tar.gz
Algorithm Hash digest
SHA256 327527bf727032f96cffc121666fa43625a6067132ac1d11c66107ecafd70083
MD5 78602e702326f499a4e38eeef3c4e1c5
BLAKE2b-256 2841d670e1c7532ef93ca436ed6e57db6e63ea1b490c63d8f33b35054a1e0916

See more details on using hashes here.

File details

Details for the file rgbterminal-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: rgbterminal-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for rgbterminal-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3bdafa12ea70dd75534aedea73a9dca95c165dbbc38e5b62754d4907dfaab327
MD5 d0d3dcd68ee3610cd60f8c687e3c96c6
BLAKE2b-256 4c0579c7bd7b7bcad2325ad0940d6bfeb32a393b1934d4fe3c5afdadd36a8591

See more details on using hashes here.

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