Almost have this quandry figured out, but inevitably a new problem has popped up. I finally have the "code" part down to do what I want, but now the font formatting isn't acting properly. When I use a simple expression with font tags I can create this image. enter image description here

However, when I use the advanced expression as follows, it returns the garbled image after. I'm using the tags the same way and can't find any reason they shouldn't be working. Without quotes I get a syntax error. EDIT - Trimmed code to focus on issue area. Font tags were improperly placed, see answer 1.

if float([Percentage_Complete]) >= 90:
lab1 =  "<bol><clr green='255'>" + lab1 + "</bol></clr>\n"
if float([Percentage_Complete1]) >= 90:
lab2 =  "<bol><clr green='255'>" +  lab2 +  "</bol></clr>\n"
if float([Percentage_Complete2]) >= 90:
lab3 =  "<bol><clr green='255'>"+  lab3 + "</bol></clr>\n"
if float([Percentage_Complete3]) >= 90:
lab4 =  "<bol><clr green='255'>"+  lab4+  "</bol></clr>\n"

enter image description here

  • I found that it might need to use the & operator to concatenate, but I get a syntax error with that as well around the lab1, etc. – twistr25 Jul 21 '14 at 18:30
  • Try enclosing them in one more set of quotations – GISKid Jul 21 '14 at 18:35
  • I get the logic, but gives me a syntax error. And that would have been ridiculous if that was necessary to make that work. Thanks for the thought though. – twistr25 Jul 21 '14 at 18:39
  • After your if statements they should also be indented – GISKid Jul 21 '14 at 18:43
  • 2
    You have the bol and clr tags end tags in the wrong order. It should be <bol><clr green='255'>"+ lab4+ "</clr></bol>\n" for each of them. – kenbuja Jul 21 '14 at 19:32

This was determined to be the issue to this problem. It will be marked as the answer soon. When using format tags make sure they close from inside out. Thanks to @kenbuja for clarifying that.

"<bol><clr green='255'>"+lab4+"</clr></bol>"

NOT "<bol><clr green='255'>"+lab4+"</bol></clr>"
  • Would you be able to edit your answer to state clearly that it does answer your question, please? Also, so others do not have to go through the same pain perhaps you can simplify your question to just the parts that in hindsight were causing all the problem so that a cleaner Q&A results? – PolyGeo Jul 21 '14 at 21:06
  • Sure I can do that, I tried to mark it as the answer, but said I had to wait two days. But I'll clean it up. – twistr25 Jul 22 '14 at 12:00

Try using the ampersand as you suggested and use vbcrlf instead of \n. I don't think \n works

"" + [PARCEL] & vbcrlf & "TEXT" & "" something like this

  • If it matters, the error I get with the & indicates a problem between 'str' and 'unicode'. I assume the unicode is my variable name lab1, lab2, etc. Oh, and I thought I mentioned it, but guess not, this is for Python not VB – twistr25 Jul 21 '14 at 18:42
  • can you convert the unicode in the attributes ? Something like str(lab1) ? – jbchurchill Jul 21 '14 at 18:49
  • Yes I suppose I wasn't thinking about the code you had there. I was thinking it was code you put in an expression. It wouldn't be easy to redo it if it were a script. Still I can run the str() python function on my attributes and it works. – jbchurchill Jul 21 '14 at 18:56
  • Another good thought, but no go. – twistr25 Jul 21 '14 at 18:56
  • It is code I put directly into the advanced expression box in the label properties under the Python parser. – twistr25 Jul 21 '14 at 18:58

This works to simply bold text and include a new line:

"<bol>" + [PointID] + "</bol>" + "\n" + [Structype] 

to get


  • This doesn't provide an answer to the question, how you set green color if the number is greater than 90? – aldo_tapia Aug 25 '17 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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