ISISComputingGroup / IBEX

Top level repository for IBEX stories
5 stars 2 forks source link

GUI genie_python: Create print colour command #2283

Open John-Holt-Tessella opened 7 years ago

John-Holt-Tessella commented 7 years ago

As a scientists I would like to colour the output from genie_python.

This is possible from by using the colours as per this snippet:

class AnsiColors:
    FG_BLACK        = '\033[30m'
    FG_RED          = '\033[31m'
    FG_GREEN        = '\033[32m'
    FG_YELLOW       = '\033[33m'
    FG_BLUE         = '\033[34m'
    FG_MAGENTA      = '\033[35m'
    FG_CYAN         = '\033[36m'
    FG_WHITE        = '\033[37m'
    BG_BLACK        = '\033[40m'
    BG_RED          = '\033[41m'
    BG_GREEN        = '\033[42m'
    BG_YELLOW       = '\033[43m'
    BG_BLUE         = '\033[44m'
    BG_MAGENTA      = '\033[45m'
    BG_CYAN         = '\033[46m'
    BG_WHITE        = '\033[47m'
    END             = '\033[0m'    

for d in dir(AnsiColors):
    if d.startswith("FG"):
        print(getattr(AnsiColors, d) + d + AnsiColors.END)
    if d.startswith("BG"):
        print(getattr(AnsiColors, d) + d + AnsiColors.END)

We should create a command which could be called colour_print(PrintColour.BLUE, "hi").

aaron-long commented 5 years ago

+1 ENGIN-X

SophieKSTFC commented 5 years ago

PyDev does not represent ANSI escape codes unlike Ipython/python which makes colouring console text in the GUI much more challenging. There is a plugin that can be loaded into eclipse to allow coloured output but trials with this were ~unsuccessful. Ticket seems to require much more work than expected.