0

I am using windows so the below colors won't work with my IDE and print statement:

HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'

print(bcolors.FAIL + bcolors.BOLD + "AN ENEMY ATTACKS!" + bcolors.ENDC)

I have relentlessly searched across ANSI sheets as well as inserted libraries but I just want to keep the above format so that I can reference the colors/bold/underline within the class (Using Windows).

Any help here would be greatly appreciated.

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
bgreen
  • 11
  • 2
  • 1
    Are you asking how to get ANSI color sequences to work on Windows or just how to store the values in a class? – jwodder Aug 24 '17 at 13:57
  • What IDE are you using? – wwii Aug 24 '17 at 14:00
  • It seems like your question is a direct copy paste from https://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python. Did you read the entire thread to look for the cross platform solutions suggested? – mgilbert Aug 24 '17 at 14:01
  • 1
    What does not work? Please be *specific about the problems you are encountering*. – juanpa.arrivillaga Aug 24 '17 at 14:14

1 Answers1

0

I found this article that might help you: https://www.burgaud.com/bring-colors-to-the-windows-console-with-python

Example:


    FOREGROUND_BLACK     = 0x0000
    FOREGROUND_BLUE      = 0x0001
    FOREGROUND_GREEN     = 0x0002
    FOREGROUND_CYAN      = 0x0003
    FOREGROUND_RED       = 0x0004
    FOREGROUND_MAGENTA   = 0x0005
    FOREGROUND_YELLOW    = 0x0006
    FOREGROUND_GREY      = 0x0007
    FOREGROUND_INTENSITY = 0x0008 # foreground color is intensified.

    BACKGROUND_BLACK     = 0x0000
    BACKGROUND_BLUE      = 0x0010
    BACKGROUND_GREEN     = 0x0020
    BACKGROUND_CYAN      = 0x0030
    BACKGROUND_RED       = 0x0040
    BACKGROUND_MAGENTA   = 0x0050
    BACKGROUND_YELLOW    = 0x0060
    BACKGROUND_GREY      = 0x0070
    BACKGROUND_INTENSITY = 0x0080 # background color is intensified.

kenfire
  • 1,305
  • 12
  • 23