qtconsole icon indicating copy to clipboard operation
qtconsole copied to clipboard

Unable to output boldface and some colors from executing python script in qtconsole.

Open chrisgmorton opened this issue 7 years ago • 5 comments

How would I go about setting a boldfaced text output? The ansi escape sequence does not work: print('\033[1m This should be boldface.') You also cannot use HTML or Markdown as neither of these work in qtconsole.

How would I go about outputting a foreground color of yellow?

print('\033[31m This is red.') print('\033[32m This is green.') print('\033[33m This is red but is supposed to be yellow.')

I noticed there is some history regarding ansi escape sequences and making text readable when using light or dark background terminal colors.

Is there a way to set boldface and yellow?

chrisgmorton avatar Feb 16 '18 23:02 chrisgmorton

I looked at ansi_code_processor.py and I can see an effort to keep output readable depending on the brightness of the background terminal color. My reference above to red being output rather than yellow is not quite correct. It is actually intentionally outputting brown which is hard to distinguish from red on a white background. It does not look like any effort was made to support boldface.

It's a shame there does not seem to be a way to allow the user direct control of output (color and other formatting) unless I'm missing something with HTML capability.

chrisgmorton avatar Feb 22 '18 23:02 chrisgmorton

Looking through ansi_code_processor.py further I see that true 24-bit colors are supported through ansi escape sequences.

print('\033[38;2;255;255;85m This is yellow.')

I suppose the bug here is that there seems to be no documentation on this at least that I could find online.

chrisgmorton avatar Feb 23 '18 17:02 chrisgmorton

Note: I think the colors part on this issue is partially caused due to the mapping (from ANSI code values to svg color names) done at: https://github.com/jupyter/qtconsole/blob/56e5a5ec5cfccf5afd098fe8bb5b2c558a1dc8f9/qtconsole/ansi_code_processor.py#L305

Changing the color name assigned to the ANSI code 3 (which should represent yellow) from a brown value to something like gold should make things look better

dalthviz avatar Jun 16 '24 16:06 dalthviz