A simple python package that allows you to colour and format text in both terminal and idle environments.
Project description
Rainbow Snake
A simple python package that allows you to colour and format text in both terminal and idle environments.
Example
from rainbowsnake import Color
Color.clear()
Color.clear()
Color.output(
f"\nWelcome to {Color.bold + Color.hexbg('#EE1C25') + Color.hextext('#ffffff')}Mushroom Cafe{Color.hexOFF + Color.boldOFF} Payroll Management \n \n"
)
Color.output(
f"{Color.warning}Please enter a number between 1 and 4{Color.warningOFF} \n"
)
Color.output("Select task:")
Color.output(f"{Color.bold}1{Color.boldOFF}. Enter hours worked")
Color.output(f"{Color.bold}2{Color.boldOFF}. Manage employees")
Color.output(f"{Color.bold}3{Color.boldOFF}. Export payroll slips")
Color.output(f"{Color.bold}4{Color.boldOFF}. View statistics \n")
Output of example
| Platform Type | Image |
|---|---|
| Terminal | |
| Idle |
About
Rainbow Snake is a python package that allows you to add colour to your command line programs.
Unlike other solutions that target terminal escape codes or idle colouring exclusively, Rainbow Snake works across all platforms, including idle and terminal based systems.
Rainbowsnake supports progressive enhancement. That means that in terminal environments it can display full hex colours, but falls back to simple colour definitions in idle.
In the terminal, Rainbowsnake can provide bold, any hex colour for text and any hex colour for background. It can also colour based on the built-in colours/symbolic styles of error, warning, success, information and important.
In idle, Rainbow Snake can only provide bold and the contextual colours of error warning success information and important.
Usage
Install Package
pip install rainbowsnake
Import color class:
from rainbowsnake import Color
Use Output [print()]
Color.output(f"Sometext")
Use Input
somevalue = Color.input(f"Enter some input: ")
Clear the Terminal
Color.clear()
Bold text
Color.output(f"{Color.bold}Sometext{Color.boldOFF}")
Symbolically Color
Available Colors
| Name | Color | Start fString Code | end fString Code |
|---|---|---|---|
| Error | Red | {Color.error} |
{Color.errorOFF} |
| Warning | Yellow | {Color.warning} |
{Color.warningOFF} |
| Success | Green | {Color.success} |
{Color.successOFF} |
| Information | Blue | {Color.information} |
{Color.informationOFF} |
| Important | Purple | {Color.important} |
{Color.importantOFF} |
Color.output(f"{Color.error}Sometext{Color.errorOFF}")
Hex Color Background
color.output( f"{color.hexbg('#EE1C25')}Sometext{color.hexOFF}")
Hex Color Text
color.output( f"{color.hextext('#EE1C25')}Sometext{color.hexOFF}")
Combining Codes
color.output( f"{color.hexbg('#EE1C25')}This text has a red background{color.hexOFF} and this is {Color.bold}bold{Color.boldOFF} and this an {Color.error}Error{Color.errorOFF}")
API Reference
Available Codes
Available Modifiers
| Name | Start fString Code | end fString Code |
|---|---|---|
| Bold | {Color.bold} |
{Color.boldOFF} |
Available Colors
| Name | Color | Start fString Code | end fString Code |
|---|---|---|---|
| Error | Red | {Color.error} |
{Color.errorOFF} |
| Warning | Yellow | {Color.warning} |
{Color.warningOFF} |
| Success | Green | {Color.success} |
{Color.successOFF} |
| Information | Blue | {Color.information} |
{Color.informationOFF} |
| Important | Purple | {Color.important} |
{Color.importantOFF} |
Hex Colors (Terminal Only)
| Type | Start Code | End Code |
|---|---|---|
| Text Color | {Color.hextext("#RRGGBB")} |
{Color.hexOFF} |
| Background Color | {Color.hexbg("#RRGGBB")} |
{Color.hexOFF} |
Functions
Color.output(string)
Prints styled text using embedded color codes.
Color.input(string)
Displays a styled prompt and returns user input.
Color.clear()
Clears the screen.
Tips
Do not nest codes
Color.output(f"{Color.error}This {Color.warning}will{Color.warningOFF} not work {Color.errorOFF}")
This will result in an error, instead, to change colors, end the current color and start the next color.
Color.output(f"{Color.error}This {Color.errorOFF}{Color.warning}will{Color.warningOFF}{Color.error} not work {Color.errorOFF}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rainbowsnake-1.0.1.tar.gz.
File metadata
- Download URL: rainbowsnake-1.0.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cb3cd400a41fc0c1a7b318fba5483969fb1088885e0583484f2430ddcbecbef
|
|
| MD5 |
a3f30e7c08a3ea456ee35d2017d11066
|
|
| BLAKE2b-256 |
c5736a799d4b770d436f7fddacfd7851e4fcc6ce2a819be096780e262fe50f3a
|
Provenance
The following attestation bundles were made for rainbowsnake-1.0.1.tar.gz:
Publisher:
python-publish.yml on Milnerrafe/Rainbow_Snake
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rainbowsnake-1.0.1.tar.gz -
Subject digest:
5cb3cd400a41fc0c1a7b318fba5483969fb1088885e0583484f2430ddcbecbef - Sigstore transparency entry: 1191445277
- Sigstore integration time:
-
Permalink:
Milnerrafe/Rainbow_Snake@774fec956540e324578a870cdc635ca60d6b9b63 -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/Milnerrafe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@774fec956540e324578a870cdc635ca60d6b9b63 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rainbowsnake-1.0.1-py3-none-any.whl.
File metadata
- Download URL: rainbowsnake-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42521085506132f157437c88bdedd0b4097037790b297be1ea552db2b71652f2
|
|
| MD5 |
1b5127d72cd958ac262b83ac0127da45
|
|
| BLAKE2b-256 |
408a1a3bc1d2dd680bcd1b931af9093d2577ea77d73dcc1bf5db27f7ef6468cc
|
Provenance
The following attestation bundles were made for rainbowsnake-1.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on Milnerrafe/Rainbow_Snake
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rainbowsnake-1.0.1-py3-none-any.whl -
Subject digest:
42521085506132f157437c88bdedd0b4097037790b297be1ea552db2b71652f2 - Sigstore transparency entry: 1191445282
- Sigstore integration time:
-
Permalink:
Milnerrafe/Rainbow_Snake@774fec956540e324578a870cdc635ca60d6b9b63 -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/Milnerrafe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@774fec956540e324578a870cdc635ca60d6b9b63 -
Trigger Event:
release
-
Statement type: