Package: colourise-output
colourise_outputDescriptionThis 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 Contentcolourise_outputDescriptionTable of ContentInstallationUsing pipUsing pythonUsageImportingInitialisingCalling the test_colours functionEpilepsy warningChanging the colourDisplaying text and the colourOnly changing the colourAvailable coloursChange the initialisation contentChanging the forbidden charactersChanging the descriptionChanging bothAuthorVersionInstallationUsing pippipinstall-Ucolorama
pipinstall-Ucolourise-outputUsing pythonUnder windows:py -m pip install -U colorama
py -m pip install -U colourise-outputUnder Linux/Mac OS:python3-mpipinstall-Ucolorama
python3-mpipinstall-Ucolourise-outputUsageImportingimportcolourise_outputascoInitialisingThe generic class is:ColouriseOutput()The generic loading function is:init_ressources(self)The output is: NoneCOI=co.ColouriseOutput()COI.init_ressources()Calling the test_colours functionThe generic function is:test_colours(self,delay:int=0)The output is: NoneCOI.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 warningWarning: Avoid this function if you are epileptic or set the delay to 1COI.test_colours(1)Changing the colourThe generic function to ask a question is: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 colourCOI.display("0A",(),"Hello World !\n")The text "Hello World" will be displayed in green (A) on a black background (0).Only changing the colouranswer=AQI.ask_question("How old are you?","uint")ADD_S=""ifanswer>1:ADD_S="s"print(f"You are{answer}year{ADD_S}old !")Available coloursHere is the windows colour pallet and how to use it:Windows colour pallet0: Black1: Blue2: Green3: Aqua4: Red5: Purple6: Yellow7: White8: Gray9: Light BlueA: Light GreenB: Light AquaC: Light RedD: Light PurpleE: Light YellowF: Bright WhiteUsing the Windows colour palletChange the initialisation contentWhen initialising the class it is possible to change the forbidden characters and/or the descriptions of the available types.changing the forbidden charactersimportask_questionasaqillegal_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 descriptionsimportask_questionasaqhuman_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 bothimportask_questionasaqillegal_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.AuthorThis module was written by (c) Henry Letellier
Attributions are appreciated.Quick way (I assume you have already initialised the class):print(f"AskQuestion is written by{AQI.author}")VersionThe current version is 1.0.0An easy way to display the version is:importask_questionasaqprint(f"Version :{aq.__Version__}")