Enabling coloured printed output #1351
Replies: 3 comments 2 replies
-
tl;dr: I managed to get coloured output in the REPL and would really like if someone else could try it and give me some feedback. Using the latest version of friendly (formally known as friendly-traceback), I managed to get coloured output in Mu's REPL working. I am planning to change the default "light" style I use so that the background would be white (instead of pale grey) and probably use a colour scheme more similar to IPython's default used by Mu. The QtConsole used by Mu has a "bug" in that a flag is hard-coded to prevent bold from being ever set by users writing Python code. I have reported this bug (spyder-ide/qtconsole#472). [1] To see the difference, I edited the code for Mu installed on my computer, and the result looks like the following: With the pygments style I currently use, it does not make a huge difference. However, I plan to modify the style so that the any Python code inside text is in bold, so that they would stand out more. This will work in Jupyter notebooks but not in the QtConsole until the bug is fixed. If one wants to use the "run" button instead of importing in the REPL, no coloured output is possible. I am wondering if it would be possible to change the "widget" used for output so that it would support ANSI escape codes for colouring, like the QtConsole currently does. [1] At some point, if no one else do it, I will try to submit a PR (simply changing a flag value from False to True). However, I currently have 5 different non-conda Python versions installed on my system (to do tests, ensuring that friendly works with Python 3.6 to 3.10) and am leery of installing a conda-based version as it messed up with my other versions in the past. |
Beta Was this translation helpful? Give feedback.
-
Hi @aroberge - just wanted to acknowledge your input. Regarding the widget used for output when the "Run" button is clicked: That's a home grown widget (for various reasons that currently escape me, we can't use the QtConsole widget for this). So the good news is someone could add the ANSI escape code handling. The bad news is someone would have to add the ANSI escape code handling. Please remember that everyone involved in Mu is a volunteer and nobody gets paid for this, so everything is done on a best effort basis. I realise this isn't helpful for you, so please don't be disheartened. A first step for this to move forward would be for you to create an issue for it so we (as Mu devs) can triage and discuss the best way to move forward (and please don't hesitate to join in with the discussion). Thank you... and it's wonderful to see all your hard work on friendly coming together. It's a really great piece of work..! 👍 |
Beta Was this translation helpful? Give feedback.
-
In case anyone is interested, when used in Mu's REPL, friendly now supports themes with backgrounds that blend in with the background for each of Mu's three themes. You can see screen captures at the bottom of page https://aroberge.github.io/friendly-traceback-docs/docs/html/mu_repl.html This has only been tested on Windows; hopefully it works correctly on other platforms. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there an "easy" way to enable coloured output in Mu?
If there is a difference interally between sys.stdout and sys.stderr, my preference would be to target sys.stderr (or its equivalent).
I realize that, even considering only the default Python mode, this is a two part question as the interpreter for the REPL mode is different from that used to run programs from the editor.
The reason I am asking this is to make the (current) experience of using Friendly-traceback (see issue #963) better for Mu users. I know that the Jupyter QtConsole used by Mu supports coloured output (for its own tracebacks), as I have mentioned on https://aroberge.github.io/friendly-traceback-docs/docs/html/mu_repl.html. I know how to do coloured output for Jupyter notebooks but not for the console used in Mu.
I do not know what output widget type exactly is used for printed output seen when running a program from the editor. All I know is that it supports a normal sys.excepthook unlike the Jupyter QtConsole which has to be "patched" in order to replace its exception handling mechanism.
Perhaps this will have to wait for third-party plugins (issue #974) for this to be adressed but, right now, Mu's integration of Friendly-traceback pales compared with what I can do with many other programming environments. I find this particularly frustrating as Mu was certainly near the top of my list of editors to support when I started working on Friendly-traceback.
Beta Was this translation helpful? Give feedback.
All reactions