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.2.0.tar.gz (4.4 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.2.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for rgbterminal-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d106ddfb1a277107a345e5a06dddbccde687dfcc4c5cba603117aabe8baee108
MD5 7c6ee81125acc480de0be713fabb1fe5
BLAKE2b-256 8a579c4848612d08eb1a9874de40d3456371de5b97d17477bfddd027050e15f5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rgbterminal-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2cbde2c006964769028d0b2641c02f9a66330537095ecbcb8db8fcb811236fc4
MD5 a5051be22743afb505247d8943d15a04
BLAKE2b-256 b1c7d32b16543d3726420a73be6199913791313cb811d9f770af2c967b619aef

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