Skip to main content

A powerful python module to set console color

Project description

Recolor

Recolor is a powerful Python module that allows you to set console colors in your Python applications. With this module, you can add color and style to the text displayed on the terminal/command prompt.

This module was created by Hamidreza Ahmadi and is available on his GitHub page under the username zhmid. You can find the source code, documentation, and examples on his page.

Installation

To install Recolor, you can use pip:

pip install recolor

Usage

To use Recolor, you can import the module and use its functions as shown in the following example:

import recolor print(recolor.colorize(255, [100],1) + "hi")

In this example, the colorize() function is used to print "hi" in a specific color with a weight of 1. The fgcolor() and bgcolor() functions can also be used to set the foreground and background colors separately, and the uncolor() function can be used to reset the console color to its default setting.

Functions

The following functions are available in the Recolor module:

  • colorize(fgcolor, bgcolor, weight=0): Returns the color code for a specific combination of foreground and background colors with a specified weight.
  • fgcolor(fgcolor): Returns the color code for a specific foreground color.
  • bgcolor(bgcolor): Returns the color code for a specific background color.
  • uncolor(): Resets the console color to its default setting.

Input Formats

The following functions are available in this module:

  • colorize
  • fgcolor
  • bgcolor
  • uncolor

colorize

The colorize function takes three arguments: fgcolor, bgcolor, and weight.

The fgcolor and bgcolor arguments specify the foreground and background colors for the output text, respectively. These arguments can be either RGB values or color names.

Accepted RGB values are arrays of three integers representing the red, green, and blue values for the desired color.

The weight argument specifies the weight (or intensity) of the text. It should be an integer between 0 and 99, with higher values indicating bolder text. The default value is 0.

fgcolor and bgcolor

These functions are simpler versions of colorize. They each take one argument, which is the color for the foreground or background, respectively. The format of this argument is the same as for fgcolor and bgcolor in colorize.

uncolor

The uncolor function returns the escape code to reset the terminal color back to its default value.

  • colorize
  • fgcolor
  • bgcolor
  • uncolor

Predetermined color

These variables are values that you can call predefined colors by calling them inner colorize(), fgcolor() & bgcolor():

  • red = [205,0,0]
  • green = (0,205,0)
  • white = (255,255,255)
  • black = (0,0,0)
  • gray = (50,50,50)
  • blue = (0,0,205)
  • yellow = (255, 230, 0)
  • magenra = (255,0,255)
  • cyan = (0,255,255)

For more information on how to use these functions, please refer to the documentation on Hamidreza Ahmadi's GitHub page.

Conclusion

With Recolor, you can easily add color and style to the text displayed on the terminal/command prompt in your Python applications. This module is easy to use and highly customizable, making it a great choice for developers who want to create eye-catching console interfaces.

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

Recolor-0.1.4.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

Recolor-0.1.4-py3-none-any.whl (2.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page