# colourise_output
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/colourise_output)
![PyPI - Implementation](https://img.shields.io/pypi/implementation/colourise_output)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/colourise_output)
![PyPI - Version](https://img.shields.io/pypi/v/colourise_output?label=pypi%20package:%20colourise_output)
![PyPI - Downloads](https://img.shields.io/pypi/dm/colourise_output)
![PyPI - License](https://img.shields.io/pypi/l/colourise_output)
![Execution status](https://github.com/Hanra-s-work/colourise_output/actions/workflows/python-package.yml/badge.svg)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/Hanra-s-work/colourise_output/python-package.yml)
![GitHub repo size](https://img.shields.io/github/repo-size/Hanra-s-work/colourise_output)
![GitHub Repo stars](https://img.shields.io/github/stars/Hanra-s-work/colourise_output)
![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/m/Hanra-s-work/colourise_output)
![GitHub last commit (branch)](https://img.shields.io/github/last-commit/Hanra-s-work/colourise_output/main)
[![Static Badge](https://img.shields.io/badge/Buy_me_a_tea-Hanra-%235F7FFF?style=flat-square&logo=buymeacoffee&label=Buy%20me%20a%20coffee&labelColor=%235F7FFF&color=%23FFDD00&link=https%3A%2F%2Fwww.buymeacoffee.com%2Fhanra)](https://www.buymeacoffee.com/hanra)
## Description
This is a module that allows you the change the colour of the terminal using the batch colour syntax.
It works on all known platforms.
## Table of Content
1. [colourise_output](#colouriseoutput)
2. [Description](#description)
3. [Table of Content](#table-of-content)
4. [Installation](#installation)
1. [Using pip](#using-pip)
2. [Using python](#using-python)
5. [Usage](#usage)
1. [Importing](#importing)
2. [Initialising](#initialising)
3. [Calling the test_colours function](#calling-the-testcolours-function)
1. [Epilepsy warning](#epilepsy-warning)
4. [Changing the colour](#changing-the-colour)
1. [Displaying text and the colour](#displaying-text-and-the-colour)
2. [Only changing the colour](#only-changing-the-colour)
6. [Available colours](#available-colours)
7. [Change the initialisation content](#change-the-initialisation-content)
1. [Changing the forbidden characters](#changing-the-forbidden-characters)
2. [Changing the description](#changing-the-descriptions)
3. [Changing both](#changing-both)
8. [Author](#author)
9. [Version](#version)
## Installation
### Using pip
```sh
pip install -U colorama
pip install -U colourise-output
```
### Using python
Under windows:
```bat
py -m pip install -U colorama
py -m pip install -U colourise-output
```
Under Linux/Mac OS:
```sh
python3 -m pip install -U colorama
python3 -m pip install -U colourise-output
```
## Usage
### Importing
```py
import colourise_output as co
```
### Initialising
The generic class is: `ColouriseOutput()`
The generic loading function is: `init_ressources(self)`
The output is: None
```py
COI = co.ColouriseOutput()
COI.init_ressources()
```
### Calling the test_colours function
The generic function is:
```py
test_colours(self, delay:int=0)
```
The output is: None
```py
COI.test_colours()
```
Calling this function will result in the function displaying all the available colours as well as their colour code (what you use to call them).
#### Epilepsy warning
Warning: Avoid this function if you are epileptic or set the delay to 1
```py
COI.test_colours(1)
```
### Changing the colour
The generic function to ask a question is:
```py
display(self, colour:str, attributes:tuple=(), text:str="")
```
The outputs of this function is: None
The terminal will display the next lines in the desired colour.
#### Displaying text and the colour
```py
COI.display("0A", (), "Hello World !\n")
```
The text "Hello World" will be displayed in green (A) on a black background (0).
#### Only changing the colour
```py
answer = AQI.ask_question("How old are you?", "uint")
ADD_S = ""
if answer > 1:
ADD_S = "s"
print(f"You are {answer} year{ADD_S} old !")
```
## Available colours
Here is the windows colour pallet and how to use it:
### Windows colour pallet
* 0: Black
* 1: Blue
* 2: Green
* 3: Aqua
* 4: Red
* 5: Purple
* 6: Yellow
* 7: White
* 8: Gray
* 9: Light Blue
* A: Light Green
* B: Light Aqua
* C: Light Red
* D: Light Purple
* E: Light Yellow
* F: Bright White
### Using the Windows colour pallet
## Change the initialisation content
When initialising the class it is possible to change the forbidden characters and/or the descriptions of the available types.
### changing the forbidden characters
```py
import ask_question as aq
illegal_characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \\t\\n\\r\\x0b\\x0c"
illegal_characters = illegal_characters.replace("0123456789","")
AQI = aq.AskQuestion(dict(), illegal_characters)
```
This initialisation has changed the characters that will be allowed for the number conversion in the 'int' and 'float' options.
### Changing the descriptions
```py
import ask_question as aq
human_type = {
"int":"whole number (-1, 0, 1, 2, 3, etc...)",
"float":"floating number (-1.2, 0.1, 1.2, etc...)",
"uint":"whole positive number (0, 1, 2, etc...)",
"ufloat":"whole positive floating number (0.1, 1.2, etc ...)",
"num":"numeric (numbers from 0 onwards)",
"alnum":"alphanumeric (only numbers and the alphabet)",
"isalpha":"alphabet (from a to z and A to Z)",
"char":"alphabet (from a to z and A to Z)",
"ascii":"ascii Table",
"str":"string (any character you can type)",
"version":"version (numbers seperated by '.' characters)",
"ver":"version (numbers seperated by '.' characters)",
"bool":"boolean (yes/True/1 or no/False/0 answer type)",
}
AQI = aq.AskQuestion(human_type)
```
This initialisation has changed the descriptions for the types.
When the user will enter a wrong answer, the description displayed for the type you were expecting will be taken from the human_type dictionnary you have entered.
### Changing both
```py
import ask_question as aq
illegal_characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \\t\\n\\r\\x0b\\x0c"
illegal_characters = illegal_characters.replace("0123456789","")
human_type = {
"int":"whole number (-1, 0, 1, 2, 3, etc...)",
"float":"floating number (-1.2, 0.1, 1.2, etc...)",
"uint":"whole positive number (0, 1, 2, etc...)",
"ufloat":"whole positive floating number (0.1, 1.2, etc ...)",
"num":"numeric (numbers from 0 onwards)",
"alnum":"alphanumeric (only numbers and the alphabet)",
"isalpha":"alphabet (from a to z and A to Z)",
"char":"alphabet (from a to z and A to Z)",
"ascii":"ascii Table",
"str":"string (any character you can type)",
"version":"version (numbers seperated by '.' characters)",
"ver":"version (numbers seperated by '.' characters)",
"bool":"boolean (yes/True/1 or no/False/0 answer type)",
}
AQI = aq.AskQuestion(human_type)
```
You have now impacted the int and float typing as well as the 'type' descriptions.
## Author
This module was written by (c) Henry Letellier
Attributions are appreciated.
Quick way (I assume you have already initialised the class):
```py
print(f"AskQuestion is written by {AQI.author}")
```
## Version
The current version is 1.0.0
An easy way to display the version is:
```py
import ask_question as aq
print(f"Version : {aq.__Version__}")
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Hanra-s-work/colourise_output",
"name": "colourise-output",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Henry Letellier",
"author_email": "henrysoftwarehouse@protonmail.com",
"download_url": "https://files.pythonhosted.org/packages/23/c5/34edff1f6347d6ccf7270f1a0442d9c6a8ed29c4a3a0de36d1ef8093f4ba/colourise_output-1.1.6.tar.gz",
"platform": null,
"description": "# colourise_output\n\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/colourise_output)\n![PyPI - Implementation](https://img.shields.io/pypi/implementation/colourise_output)\n![PyPI - Wheel](https://img.shields.io/pypi/wheel/colourise_output)\n![PyPI - Version](https://img.shields.io/pypi/v/colourise_output?label=pypi%20package:%20colourise_output)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/colourise_output)\n![PyPI - License](https://img.shields.io/pypi/l/colourise_output)\n![Execution status](https://github.com/Hanra-s-work/colourise_output/actions/workflows/python-package.yml/badge.svg)\n![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/Hanra-s-work/colourise_output/python-package.yml)\n![GitHub repo size](https://img.shields.io/github/repo-size/Hanra-s-work/colourise_output)\n![GitHub Repo stars](https://img.shields.io/github/stars/Hanra-s-work/colourise_output)\n![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/m/Hanra-s-work/colourise_output)\n![GitHub last commit (branch)](https://img.shields.io/github/last-commit/Hanra-s-work/colourise_output/main)\n\n[![Static Badge](https://img.shields.io/badge/Buy_me_a_tea-Hanra-%235F7FFF?style=flat-square&logo=buymeacoffee&label=Buy%20me%20a%20coffee&labelColor=%235F7FFF&color=%23FFDD00&link=https%3A%2F%2Fwww.buymeacoffee.com%2Fhanra)](https://www.buymeacoffee.com/hanra)\n\n## Description\n\nThis is a module that allows you the change the colour of the terminal using the batch colour syntax.\nIt works on all known platforms.\n\n## Table of Content\n\n1. [colourise_output](#colouriseoutput)\n2. [Description](#description)\n3. [Table of Content](#table-of-content)\n4. [Installation](#installation)\n 1. [Using pip](#using-pip)\n 2. [Using python](#using-python)\n5. [Usage](#usage)\n 1. [Importing](#importing)\n 2. [Initialising](#initialising)\n 3. [Calling the test_colours function](#calling-the-testcolours-function)\n 1. [Epilepsy warning](#epilepsy-warning)\n 4. [Changing the colour](#changing-the-colour)\n 1. [Displaying text and the colour](#displaying-text-and-the-colour)\n 2. [Only changing the colour](#only-changing-the-colour)\n6. [Available colours](#available-colours)\n7. [Change the initialisation content](#change-the-initialisation-content)\n 1. [Changing the forbidden characters](#changing-the-forbidden-characters)\n 2. [Changing the description](#changing-the-descriptions)\n 3. [Changing both](#changing-both)\n8. [Author](#author)\n9. [Version](#version)\n\n## Installation\n\n### Using pip\n\n```sh\npip install -U colorama\npip install -U colourise-output\n```\n\n### Using python\n\nUnder windows:\n\n```bat\npy -m pip install -U colorama\npy -m pip install -U colourise-output\n```\n\nUnder Linux/Mac OS:\n\n```sh\npython3 -m pip install -U colorama\npython3 -m pip install -U colourise-output\n```\n\n## Usage\n\n### Importing\n\n```py\nimport colourise_output as co\n```\n\n### Initialising\n\nThe generic class is: `ColouriseOutput()`\nThe generic loading function is: `init_ressources(self)`\nThe output is: None\n\n```py\nCOI = co.ColouriseOutput()\nCOI.init_ressources()\n```\n\n### Calling the test_colours function\n\nThe generic function is:\n\n```py\ntest_colours(self, delay:int=0)\n```\n\nThe output is: None\n\n```py\nCOI.test_colours()\n```\n\nCalling this function will result in the function displaying all the available colours as well as their colour code (what you use to call them).\n\n#### Epilepsy warning\n\nWarning: Avoid this function if you are epileptic or set the delay to 1\n\n```py\nCOI.test_colours(1)\n```\n\n### Changing the colour\n\nThe generic function to ask a question is:\n\n```py\ndisplay(self, colour:str, attributes:tuple=(), text:str=\"\")\n```\n\nThe outputs of this function is: None\nThe terminal will display the next lines in the desired colour.\n\n#### Displaying text and the colour\n\n```py\nCOI.display(\"0A\", (), \"Hello World !\\n\")\n```\n\nThe text \"Hello World\" will be displayed in green (A) on a black background (0).\n\n#### Only changing the colour\n\n```py\nanswer = AQI.ask_question(\"How old are you?\", \"uint\")\nADD_S = \"\"\nif answer > 1:\n ADD_S = \"s\"\nprint(f\"You are {answer} year{ADD_S} old !\")\n```\n\n## Available colours\n\nHere is the windows colour pallet and how to use it:\n\n### Windows colour pallet\n\n* 0: Black\n* 1: Blue\n* 2: Green\n* 3: Aqua\n* 4: Red\n* 5: Purple\n* 6: Yellow\n* 7: White\n* 8: Gray\n* 9: Light Blue\n* A: Light Green\n* B: Light Aqua\n* C: Light Red\n* D: Light Purple\n* E: Light Yellow\n* F: Bright White\n\n### Using the Windows colour pallet\n\n## Change the initialisation content\n\nWhen initialising the class it is possible to change the forbidden characters and/or the descriptions of the available types.\n\n### changing the forbidden characters\n\n```py\nimport ask_question as aq\nillegal_characters = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\\\"#$%&\\'()*+,-./:;<=>?@[\\\\]^_`{|}~ \\\\t\\\\n\\\\r\\\\x0b\\\\x0c\"\nillegal_characters = illegal_characters.replace(\"0123456789\",\"\")\nAQI = aq.AskQuestion(dict(), illegal_characters)\n```\n\nThis initialisation has changed the characters that will be allowed for the number conversion in the 'int' and 'float' options.\n\n### Changing the descriptions\n\n```py\nimport ask_question as aq\nhuman_type = {\n \"int\":\"whole number (-1, 0, 1, 2, 3, etc...)\",\n \"float\":\"floating number (-1.2, 0.1, 1.2, etc...)\",\n \"uint\":\"whole positive number (0, 1, 2, etc...)\",\n \"ufloat\":\"whole positive floating number (0.1, 1.2, etc ...)\",\n \"num\":\"numeric (numbers from 0 onwards)\",\n \"alnum\":\"alphanumeric (only numbers and the alphabet)\",\n \"isalpha\":\"alphabet (from a to z and A to Z)\",\n \"char\":\"alphabet (from a to z and A to Z)\",\n \"ascii\":\"ascii Table\",\n \"str\":\"string (any character you can type)\",\n \"version\":\"version (numbers seperated by '.' characters)\",\n \"ver\":\"version (numbers seperated by '.' characters)\",\n \"bool\":\"boolean (yes/True/1 or no/False/0 answer type)\",\n}\nAQI = aq.AskQuestion(human_type)\n```\n\nThis initialisation has changed the descriptions for the types.\nWhen the user will enter a wrong answer, the description displayed for the type you were expecting will be taken from the human_type dictionnary you have entered.\n\n### Changing both\n\n```py\nimport ask_question as aq\nillegal_characters = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\\\"#$%&\\'()*+,-./:;<=>?@[\\\\]^_`{|}~ \\\\t\\\\n\\\\r\\\\x0b\\\\x0c\"\nillegal_characters = illegal_characters.replace(\"0123456789\",\"\")\nhuman_type = {\n \"int\":\"whole number (-1, 0, 1, 2, 3, etc...)\",\n \"float\":\"floating number (-1.2, 0.1, 1.2, etc...)\",\n \"uint\":\"whole positive number (0, 1, 2, etc...)\",\n \"ufloat\":\"whole positive floating number (0.1, 1.2, etc ...)\",\n \"num\":\"numeric (numbers from 0 onwards)\",\n \"alnum\":\"alphanumeric (only numbers and the alphabet)\",\n \"isalpha\":\"alphabet (from a to z and A to Z)\",\n \"char\":\"alphabet (from a to z and A to Z)\",\n \"ascii\":\"ascii Table\",\n \"str\":\"string (any character you can type)\",\n \"version\":\"version (numbers seperated by '.' characters)\",\n \"ver\":\"version (numbers seperated by '.' characters)\",\n \"bool\":\"boolean (yes/True/1 or no/False/0 answer type)\",\n}\nAQI = aq.AskQuestion(human_type)\n```\n\nYou have now impacted the int and float typing as well as the 'type' descriptions.\n\n## Author\n\nThis module was written by (c) Henry Letellier\nAttributions are appreciated.\n\nQuick way (I assume you have already initialised the class):\n\n```py\nprint(f\"AskQuestion is written by {AQI.author}\")\n```\n\n## Version\n\nThe current version is 1.0.0\n\nAn easy way to display the version is:\n\n```py\nimport ask_question as aq\nprint(f\"Version : {aq.__Version__}\")\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "A module to help add colour in the terminal using batch colour codes.",
"version": "1.1.6",
"project_urls": {
"Homepage": "https://github.com/Hanra-s-work/colourise_output"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "24c5c4329d48992258b61bc0a31bf9514e368e36f43b4f560770672b6bef5ca0",
"md5": "737cb0eeb60bbe69960779eb8041b0e3",
"sha256": "3b768306f28a8dd0484a8d515bc2cf7b16bf8fafbac769bad9af3869d8f67b95"
},
"downloads": -1,
"filename": "colourise_output-1.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "737cb0eeb60bbe69960779eb8041b0e3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10397,
"upload_time": "2024-08-24T16:27:56",
"upload_time_iso_8601": "2024-08-24T16:27:56.524200Z",
"url": "https://files.pythonhosted.org/packages/24/c5/c4329d48992258b61bc0a31bf9514e368e36f43b4f560770672b6bef5ca0/colourise_output-1.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "23c534edff1f6347d6ccf7270f1a0442d9c6a8ed29c4a3a0de36d1ef8093f4ba",
"md5": "8bfd844ed2dbc724e3b1a9e2a7c200db",
"sha256": "7a87bceaee4540b51f377317edb88e974d9baa46257111a029e702cc377c0739"
},
"downloads": -1,
"filename": "colourise_output-1.1.6.tar.gz",
"has_sig": false,
"md5_digest": "8bfd844ed2dbc724e3b1a9e2a7c200db",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11849,
"upload_time": "2024-08-24T16:27:57",
"upload_time_iso_8601": "2024-08-24T16:27:57.859515Z",
"url": "https://files.pythonhosted.org/packages/23/c5/34edff1f6347d6ccf7270f1a0442d9c6a8ed29c4a3a0de36d1ef8093f4ba/colourise_output-1.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-24 16:27:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Hanra-s-work",
"github_project": "colourise_output",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "colourise-output"
}