1

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

asked Oct 19, 2023 at 21:20
5
  • 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. Commented Oct 20, 2023 at 5:26
  • ArcPy with ArcGIS Pro would be preferred. I'll update my post with that info. 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. 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. 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. Commented Oct 23, 2023 at 9:26

2 Answers 2

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

answered Oct 20, 2023 at 8:15
1
  • I'm looking for the ArcGIS process dialog box. Commented Oct 20, 2023 at 17:09
0

Just was informed that colors can be used - not sure when this was updated. Check out the example below.

enter image description here

answered Aug 13 at 17:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.