| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Copy the color.py file to your project, then:
from yourproject import color
# 8 bit color
print(color.red('red') + color.green('green') + color.blue('blue'))
print(color.bold(color.yellow('bold yellow')) + color.underline(color.cyan('underline cyan')))
print(color.magenta_hl('magenta highlight'))
# xterm 256 color
print(color.bg256('A9D5DE', color.fg256('276F86', 'Info!')))
print(color.bg256('E0B4B4', color.fg256('912D2B', 'Warning!')))
print(color.hl256('10a3a3', 'Teal'))Note:
Decorate string with specified color.
color_function is one of below function names:
| Colors | Background | Highlight |
|---|---|---|
| black | black_bg | black_hl |
| red | red_bg | red_hl |
| green | green_bg | green_hl |
| yellow | yellow_bg | yellow_hl |
| blue | blue_bg | blue_hl |
| magenta | magenta_bg | magenta_hl |
| cyan | cyan_bg | cyan_hl |
| white | white_bg | white_hl |
A color function with _bg suffix means it will set color as background. A color function with _hl suffix means it will set color as background, and change the foreground as well to make the word standout.
Parameters:
| param str s: | The input string |
|---|---|
| return: | The decorated string |
| rtype: | string |
| raises ValueError: | if the message_body exceeds 160 characters |
Decorate string with specified style.
style_function is one of below function names:
Arguments and return are the same as color_function.
Decorate string with specified hex rgb color
256_color_function is one of below function names:
Parameters:
| param str hexrgb: | The hex rgb color string, accept length 3 and 6. eg: 555, 912D2B |
|---|---|
| param str s: | The input string |
| return: | The decorated string |
| rtype: | string |
| raises ValueError: | If the input string's length not equal to 3 or 6. |
| Back | FazBrowse Home | New Git URL |