0

I recently came across a post about changing "the default error color in python" and was interested in doing something similar with Arcpy's AddMessage, AddWarning, and/or AddError functions. A few older posts like arcpy.AddMessage Formatting were made on Esri's site claiming that it's not possible, though they are quite a bit old.

Has there been any updates or workaround solutions?

I would assume that the message functions have some sort of html text coloring schema that they are following and are pulled from some file. Not sure if that comes from another python library, an OS setting, something Esri specifically built, etc.

If in fact AddMessage, AddWarning, AddError text color cannot be changed, would it be feasible to write a custom function or class that would be able to do this or is this a foundational issue with the processing dialog box?

Using ArcPy Pro.

enter image description here

7
  • Are you trying to do this using ArcPy with ArcGIS Pro or ArcPy with ArcMap? It may be the same answer for both but focusing on the former will be important when asking for an enhancement or lifting of a software limitation at ArcGIS Ideas.
    – PolyGeo
    Commented Oct 20, 2023 at 5:26
  • ArcPy with ArcGIS Pro would be preferred. I'll update my post with that info.
    – Binx
    Commented Oct 20, 2023 at 17:04
  • I regularly develop python code to be run as script tools so use the messaging system that arcpy provides to write messages to the dialog box. I know of now way to alter the colour of the messages.
    – Hornbydd
    Commented Oct 21, 2023 at 0:19
  • @Hornbydd sorry I am having a hard time reading your comment. Are you saying just print everything to the terminal and change the color there (like what Berend has answered below)? The print statements are necessarily for me, but others that are using the tool. So keeping everything in the Dialog box is preferred.
    – Binx
    Commented Oct 22, 2023 at 23:48
  • 1
    No I'm just agreeing with you. You have no control over the text colour when writing to the message dialog.
    – Hornbydd
    Commented Oct 23, 2023 at 9:26

1 Answer 1

0

It depends on where you want to see colors, in a text editor, in the console, in ArcGIS desktop?

Some text editors support coloring based on text content, either native or with a plugin.

For consoles that support Ansi escape sequences, you could use those in the output. For instance, arcpy.AddMessage("\u001B[31mRed\u001B[0m") will output text in red.

Red output text

1
  • I'm looking for the ArcGIS process dialog box.
    – Binx
    Commented Oct 20, 2023 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.