Package: pyTextColor
pyTextColor v1.0IntroductionpyTextColor is a simple Python Library to display colorful outputs in Terminal, etc.Note: Your Terminal or any software in which you are going to print a text should support the ANSI Escape Sequences or
it may not work!InstallTo install this library, typepip install pyTextColorin the Terminal(command prompt)ImportTo import the library, use the following code:importpyTextColorPrint Basic Colored OutputSee the following program to print a colorful text in Python!importpyTextColor# Import the librarypytext=pyTextColor.pyTextColor()# Create an object of the pyTextColor classtext=pytext.format_text(text="Hi!",color="white",bgcolor="black")# Format the text with the color/bgcolor of your choiceprint(text)# Print the textThe above program will give the output as:You can also change the style/color/background of the text!Following is a list of all color names you can use for both background and text:blackredgreenyellowbluemagentacyanwhiteNote: You can also use HEX color values to color a text or background. Remember: HEX color values should have '#'
before the main color valueExample Code:importpyTextColorpytext=pyTextColor.pyTextColor()text=pytext.format_text(text="This text will be printed out in yellow color with red background",color="#ff0000",bgcolor="#FFFF00")# HEX valuesprint(text)# Print the textThe output of the above code will be:Text StylesThere are many text styles you can use. Use thetext_styleparameter to change the text style. Example code:importpyTextColorpytext=pyTextColor.pyTextColor()text=pytext.format_text(text="I am bold text",color="#ff0000",bgcolor="#FFFF00",text_style="bold")# bold textprint(text)# Print the textThe output of the above program will be:There are many text styles you can use! See the list of available styles:normal> for normal textbold> for bold textfaint> for faint textitalic> for italic textunderline> for underlined textblink> for blinking textreverse> for reversed text. The color of the text will be changed to background color while the background
color will be changed to text colorhidden> for hidden textstrikethrough> for strikethrough textPrint the documentationTo pretty print the documentation for this library, run the following code:importpyTextColorpytext=pyTextColor.pyTextColor()pytext.pretty_print_help()# Print the docsThe output will be:Parameters of theformat_text()functionTheformat_text()function has many parameters such as:text> The text you wantcolor> The color you wantbgcolor> The background color you wanttext_style> The text style you wantbg_full_line> Set this toTrueif you want the background color to be printed on full lineMake output fully customised?See the following program to make the output fully customized:importpyTextColorpytext=pyTextColor.pyTextColor()color=pytext.color# Color Functionstyle=pytext.style# Style Functionbg=pytext.background# Background Functionreset=pytext.reset# Reset Function (To reset all styles/colors/etc.)name="Siddhesh"age=15hobby="programming"text=f"""{bg("black")}{color("#ffffff")}Hi! I am{color("magenta")}{name}{color("#ffffff")}. I am{color("magenta")}{age}{color("#ffffff")}years old. My favourite hobby is{color("green")}{style("italic")}{hobby}{reset()}"""# Make an f-string and edit the textprint(text)# Print the outputThe output will be:Remember to use thereset()function or the normal text will be printed out with styles when you print a text
below the styled text.Thank you!